Forum Discussion

Babycakes's avatar
Babycakes
Icon for Helper II rankHelper II
4 years ago
Solved

Variance between summed value and actual value

Actual contract hours]is a set value coming from data set based on staff name, Total shift hours is a sum of all shifts

 

How do i get Total shift - hours less sum

 

AH = Sum('PW Staff Templated Hours Report'[Total shift hours])

RH = sum('PW Staff Templated Hours Report'[Actual contract hours])

Diff = [AH]-[RH]

 

Using "RH = sum('PW Staff Templated Hours Report'[Actual contract hours])" doesnt work as its summing and want acutal value, eg 68-74 =-6

 

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Babycakes ,

    Please try below steps:

    1. create a measure with below dax formula

    Sum for Diff =
    VAR a =
        SELECTEDVALUE ( 'Table'[Actual contract hours] )
            - SELECTEDVALUE ( 'Table'[Total shift hours] )
    RETURN
        SUMX ( 'Table', a )
    

    2. add a table visual then add fields and add the measure

    If I have misunderstood your request, please feel free to let me know.

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

2 Replies

  • Babycakes ,
    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

     

    You might need Sumx(Values(Table[Shift]),  [AH]-[RH])

     

    or

    Sumx(Values(Table[Employee]),  [AH]-[RH])

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Babycakes ,

    Please try below steps:

    1. create a measure with below dax formula

    Sum for Diff =
    VAR a =
        SELECTEDVALUE ( 'Table'[Actual contract hours] )
            - SELECTEDVALUE ( 'Table'[Total shift hours] )
    RETURN
        SUMX ( 'Table', a )
    

    2. add a table visual then add fields and add the measure

    If I have misunderstood your request, please feel free to let me know.

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.