Forum Discussion
DATEDIFF as DAX Measure
- 6 years ago
You could try either of these measure expressions
TimeDiff = SUMX(Table, Table[TimeColumn1] - Table[TimeColumn2]
or
TimeDiff = SUMX(Table, DATEDIFF(Table[TimeColumn1], Table[TimeColumn2], MINUTE))If you make a table visual with both time columns, you should see the difference when you add the measure. Or you could use the aggregate, maybe switching to AVERAGEX, MAXX, etc. depending on what you are looking for.
Also, there are probably more impactful ways to reduce the file size of your model.
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
Anonymous ,
[Date1] -[Date2] will give in that format.
If you get in in second, minute or hour refer this for the duration of your choice
- Anonymous6 years agoNot applicable
The DAX measure does not give me the option to call the entire column, so I cannot use [Date 1] - [Date 2]. In this case I would need a function that allows me to subtract 2 columns that are in the date format.
- amitchandak6 years ago
Super User
Anonymous , in Measure you need to
measure = max([Date1]) -min([Date2])
Take care row context while using. refer this blog how summarize and valuea has been used
- Anonymous6 years agoNot applicable
I tried that measure and when I put it in a table it only gives one value. I am trying to replicate the following column as a DAX measure:
This was calculated using the following calculation:
Start Time Variance =DATEDIFF('bv AFKO: Order Header Data PP Orders'[GSUZS_SIMP_TM: (GC) Scheduled Start (Time)] , 'bv AFKO: Order Header Data PP Orders'[GSUZI_SIMP_TM: (GC) Actual start time] , MINUTE) / 60The columns in the calculation are the following: