Forum Discussion

dbollini's avatar
dbollini
Helper II
3 years ago
Solved

Calculate the difference between two hour columns numeric values after certain conditions

I want to calculate the hours difference between Total Hours 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 ...
  • amitchandak's avatar
    3 years ago

    dbollini , check if this can help

    CalculatedColumn =
    VAR MaxDate = TODAY()
    VAR OneMonthAgo = EOMONTH(MaxDate, -1)

    RETURN
    IF(
    'Table'[Active] = 1 &&
    'Table'[ApprovalStatusID] IN {5, 7, 8} &&
    'Table'[OriginalWorkHours] <> 'Table'[Total Hours] &&
    NOT(ISBLANK('Table'[OriginalWorkHours])) &&
    'Table'[ApprovalDateTime] > DATEADD(OneMonthAgo, -1, DAY),
    'Table'[OriginalWorkHours] - 'Table'[Total Hours],
    BLANK()
    )

     

     

  • sergej_og's avatar
    sergej_og
    3 years ago

    what happens when you adjust 'Table'[ApprovalDateTime] > DATEADD(OneMonthAgo, -1, DAY) to

    'Table'[ApprovalDateTime] > DATEADD('Calendar'[Date], -1, DAY)?