Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello all,
I am trying to create a measure that calculates the difference between 2 time columns (hh:mm:ss format) and gives a result as a decimal. DATEDIFF works as a calculated column, but I cannot figure out how to translate to a DAX Measure. My report is saying there is too much space being taken up, so I want to change these columns to measures.
Please help!
Solved! Go to Solution.
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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@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
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.
@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
Hello, hoping you can read my last reply and provide some assistance please. I have a hard deadline for this project and I'm really trying to deliver it. Thank you!
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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Second measure worked using MAXX. Thank you very much!!!
Additionally, could you tell me what are the best ways to substantially reduce file size?
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:
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 22 | |
| 10 | |
| 10 | |
| 7 | |
| 5 |