Forum Discussion
Samcooke
3 years agoFrequent Visitor
Date Diff between two tables
Hi I am a longtime Tableau user that is moving our customer base over to Power Bi. In Tableau one of the key calculations I used was Date Diff using two different tables. Essentially comparing counti...
Greg_Deckler
3 years agoCommunity Champion
Samcooke I recommend not using DAX TI functions like DATEDIFF. All you have to do is get your two dates into variables and essentially subtract them like this:
Measure =
VAR __Date1 = // some DAX to get your date in first table
VAR __DAte2 = // some DAX to get your date in second table
RETURN
( __Date1 - __Date2 ) * 1. // this just makes sure you get a number value back, set your data type to Whole number.
Dates in DAX are a decimal number where the integer portion is the number of days since December 30th, 1899 and the decimal portion is fraction of a day 24/60/60.
Samcooke
3 years agoFrequent Visitor
Thanks so much for commenting. I am still struggling. How to you get your dates into variables?