Calculations

Explore our collection of ready-to-use Tableau calculations that have been used in real-time scenarios. These calculations cover a wide range of string, table, and date calculations. Simply click on 'Learn More' to discover the full list of calculations and start using them in your next project.
Click on the topic below to see the calculation

Date calculations:

``````
[Date] <= TODAY() AND DATETRUNC( "year", [Date]) = DATETRUNC("year", TODAY() ) ``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st Jan 2022 to 11th June 2022
``````
DATEDIFF('month',[Date],Today()) > 0 AND  DATEDIFF('year',[Date],Today())= 0``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st Jan 2022 to 31st May 2022
``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st Jan 2021 to 11th June 2021
``````
DATEDIFF('quarter',[Date],TODAY())=0 AND [Date]<=TODAY() ``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st Apr 2022 to 11th June 2022
``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st Jan 2022 to 11th Mar 2022
``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st Apr 2021 to 11th June 2021
``````
[Date] <= TODAY() AND DATETRUNC( "month", [Date]) = DATETRUNC("month", TODAY() ) ``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st June 2022 to 11th June 2022
``````
Method 1: DATEDIFF('month',[Date],TODAY())=1 AND DAY([Date])<=DAY(TODAY())  Method 2: DATEDIFF('month',[Date],TODAY())=1 AND [Date]<=DATEADD('month',-1,TODAY())
``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st May 2022 to 11th May 2022
``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st June 2021 to 11th June 2021
``````
Method 1: [Date] >= DATEADD('day',-30,TODAY()) AND  [Date] <= TODAY()
Method 2: DATEDIFF('day',[Date],TODAY())<=30 AND  [Date] <= TODAY() ``````
``````
For example, if today's date is 16th June 2022. This boolean calculation returns true for the period starting from 17th may 2022 to 16th June 2022

``````
Step 1: Calculation to date difference in seconds DATEDIFF('second',[Open Date],([Closed Date]))
Step 2: Avg Duration Calculation IIF([Seconds] % 60 == 60,0,[Seconds] % 60)// seconds
+ IIF(INT([Seconds]/60) %60 == 60, 0, INT([Seconds]/60) %60) * 100 //minutes
+ IIF(INT([Seconds]/3600) % 24 == 0, 0, INT([Seconds]/3600) % 24) * 10000 //hours
+ INT([Seconds]/86400) * 1000000 // days ``````
``````
Note: Here [Seconds] is the name of the calculation from step 1

``````
DATEDIFF('year',[Date],TODAY())=0``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st Jan 2022 to 31st Dec 2022
``````
DATEDIFF('year',[Date],TODAY())=1``````
For example, if today's date is 11th June 2022. This boolean calculation returns true for the period starting from 1st Jan 2021 to 31st Dec 2021. (Assuming there is no data for future dates)