Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
dbollini
Helper II
Helper II

Calculate the difference between two hour columns and compare it to last month date

Hello,

 

 

I want to calculate the hours difference between Total Hours has decimal values and orginal work hours which has date slicer .

Dax Query should be written as below and after this conditions have been met then have to calculate the difference between orginal workhours and Total hours

 

WHERE PROJ.Active = 1 AND TAR.ApprovalStatusID IN (5,7,8)

(TAE.OriginalWorkHours,0) != TAE.Total Hours

     TAE.OriginalWorkHours is not null

     TAR.ApprovalDateTime>DATEADD(s, -1, DATEADD(m, DATEDIFF(m, 0, @pendwkdate)+1, 0))

then difference between orginalworkhours-Totalhours

 
dbollini_0-1690239459569.png

 

 
2 REPLIES 2
Anonymous
Not applicable

Hi @dbollini 

If you want Total hour to be unaffected by slicer, you can modify your Test Measure Hours as follows.

Test Measure Hours =
VAR a =
    CALCULATE (
        SUM ( 'ATAS REPORT'[Total Hours] ),
        ALLEXCEPT ( 'ATAS REPORT', 'ATAS REPORT'[Name] )
    )
RETURN
    a - SUM ( 'ATAS REPORT'[OriginalWorkHours] )

If the following above cannot meet your requirement, can you provide more detail expression?

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you but now the requirements have been modified first i have to check if the below conditions have been met and then should calculate the difference between orginalwkhours and Total hours

 

isnull(TAE.OriginalWorkHours,0) != TAE.WkHours

TAE.OriginalWorkHours is not null

TAR.ApprovalDateTime>DATEADD(s, -1, DATEADD(m, DATEDIFF(m, 0, @pendwkdate)+1, 0))

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.