Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi all,
I am having difficulty in total sum for the below scenario:
I am simply doing the time difference between start and end date. At the row level it is working perfectly but total is not correct. I am using the below measure:
Solved! Go to Solution.
@TaroGulati , Try creating a measure using
DAX
Time Difference =
VAR TotalSeconds = DATEDIFF(MIN('Table'[Start Date]), MAX('Table'[End Date]), SECOND)
VAR Result_hour = INT(TotalSeconds / 3600)
VAR Result_minutes = INT(MOD(TotalSeconds, 3600) / 60)
VAR Result_second_final = MOD(TotalSeconds, 60)
RETURN FORMAT(Result_hour, "00") & ":" & FORMAT(Result_minutes, "00") & ":" & FORMAT(Result_second_final, "00")
Proud to be a Super User! |
|
Hi @TaroGulati ,
Update your DAX measure to look like this:
Time Difference =
VAR TotalSeconds =
SUMX(
'Table',
DATEDIFF('Table'[Start Date], 'Table'[End Date], SECOND)
)
VAR TotalHours = INT(TotalSeconds / 3600)
VAR TotalMinutes = INT(MOD(TotalSeconds, 3600) / 60)
VAR TotalSecondsFinal = MOD(TotalSeconds, 60)
RETURN
FORMAT(TotalHours, "00") & ":" & FORMAT(TotalMinutes, "00") & ":" & FORMAT(TotalSecondsFinal, "00")
Your output will look like this:
Hi @TaroGulati ,
Pls has your problem been solved? If so, accept the helpful replies as solutions. This will make it easier for the future people to find the answer quickly.
If not, please provide a more detailed description, preferably some virtual sample data, and the expected results.
Best Regards,
Stephen Tao
Hi @TaroGulati ,
Update your DAX measure to look like this:
Time Difference =
VAR TotalSeconds =
SUMX(
'Table',
DATEDIFF('Table'[Start Date], 'Table'[End Date], SECOND)
)
VAR TotalHours = INT(TotalSeconds / 3600)
VAR TotalMinutes = INT(MOD(TotalSeconds, 3600) / 60)
VAR TotalSecondsFinal = MOD(TotalSeconds, 60)
RETURN
FORMAT(TotalHours, "00") & ":" & FORMAT(TotalMinutes, "00") & ":" & FORMAT(TotalSecondsFinal, "00")
Your output will look like this:
Hi @TaroGulati - you can use a measure that correctly calculates the total time difference for all rows without reformatting until the final step
create measure as below:
Time Difference =
VAR TotalSeconds =
SUMX(
'Table',
DATEDIFF('Table'[Start Date], 'Table'[End Date], SECOND)
)
VAR Hours = INT(TotalSeconds / 3600)
VAR Minutes = INT(MOD(TotalSeconds, 3600) / 60)
VAR Seconds = MOD(TotalSeconds, 60)
RETURN
FORMAT(Hours, "00") & ":" & FORMAT(Minutes, "00") & ":" & FORMAT(Seconds, "00")
It avoids the row-level formatting issue and ensures that the total at the bottom of the table is calculated correctly.
Proud to be a Super User! | |
@TaroGulati , Try creating a measure using
DAX
Time Difference =
VAR TotalSeconds = DATEDIFF(MIN('Table'[Start Date]), MAX('Table'[End Date]), SECOND)
VAR Result_hour = INT(TotalSeconds / 3600)
VAR Result_minutes = INT(MOD(TotalSeconds, 3600) / 60)
VAR Result_second_final = MOD(TotalSeconds, 60)
RETURN FORMAT(Result_hour, "00") & ":" & FORMAT(Result_minutes, "00") & ":" & FORMAT(Result_second_final, "00")
Proud to be a Super User! |
|
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
85 | |
66 | |
51 | |
45 |
User | Count |
---|---|
216 | |
89 | |
82 | |
66 | |
57 |