Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I am trying to calculate the difference in minutes between the date/time values in my table, to end up with a new column called "Diff" like in the example below.
I looked at similar example but couldn't get these working due to extra fields being used whereas i'm hoping this is much simpler as its just one column with date and time in.
Can anyone show me what the DAX would be for this and if it should be a measure or calculated column?
Thanks
Hi @rogerdea ,
According to your descriptions, i guess you add a measure with @Fowmy dax formula to table visual. if you want to show the date according to the filter, please add a new column to the original table, then add the datetime column to slicer visual.
Best regards,
Community Support Team_ Binbin Yu
@rogerdea
Add the following DAX code in a new calculated column:
Diff in Minutes =
VAR __CURRTIME = 'Table1'[DateTime]
VAR __LASTTIME =
CALCULATE(
MAX('Table1'[DateTime]),
'Table1'[DateTime]<__CURRTIME,
REMOVEFILTERS('Table1')
)
VAR __RESULT =
DATEDIFF( __LASTTIME, __CURRTIME , MINUTE )
RETURN
__RESULT
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Thank you @Fowmy
I've applied that solution to my data but it's giving strange results, and i'm not sure why. I've pasted the DAX with the actual real table names, have i applied the solution correctly?
Thanks
@rogerdea
Did add a Measure or a Calculated Column ?
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
I figured out why it wasn't working. I had a filter on the data which the code ignores, so the DAX is actually fine.
Is it possible to remove the REMOVEFILTERS part and have it working so that the dates dynamically change according to what filters are being used? I tried deleting that part but the calculation broke.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |