Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

help in dax

Need help in calculating the delta( IN SAME matrix table below) between 2020H1 and 2019 H2 from the below matrix

I have columns like 

Year: 2019, 2020

Bundle name : Mobility, Mathworks

Half year: H1, H2

Cost: the values in K

On expanding the bundles, will have employee name.

 

 

 

  • Hi Anonymous 

    Create a measure

    Measure =
    VAR diff =
        CALCULATE (
            SUM ( 'Table 2'[value] ),
            FILTER ( 'Table 2', 'Table 2'[year] = 2020 && 'Table 2'[half year] = "h1" )
        )
            - CALCULATE (
                SUM ( 'Table 2'[value] ),
                FILTER ( 'Table 2', 'Table 2'[year] = 2019 && 'Table 2'[half year] = "h2" )
            )
    RETURN
        IF ( ISINSCOPE ( 'Table 2'[year] ), SUM ( 'Table 2'[value] ), diff )
    

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      I want to calculate teh difference between 2020H1 and 2019 H2 in the same matrix.

  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous 

    Create a measure

    Measure =
    VAR diff =
        CALCULATE (
            SUM ( 'Table 2'[value] ),
            FILTER ( 'Table 2', 'Table 2'[year] = 2020 && 'Table 2'[half year] = "h1" )
        )
            - CALCULATE (
                SUM ( 'Table 2'[value] ),
                FILTER ( 'Table 2', 'Table 2'[year] = 2019 && 'Table 2'[half year] = "h2" )
            )
    RETURN
        IF ( ISINSCOPE ( 'Table 2'[year] ), SUM ( 'Table 2'[value] ), diff )
    

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.