Forum Discussion

Sudharsanan's avatar
Sudharsanan
Icon for Helper III rankHelper III
4 years ago
Solved

Sum data based on product availability by comparing years.

Hi All,

 

Can someone help me with the below scenerio?

 

I wanted to sum the price when the product is available on both 2022 and 2021? is this something we can get using DAX?

Appreciate your support!!

 

  • SpartaBI's avatar
    SpartaBI
    4 years ago

    Sudharsanan 

     

    Result = 
    VAR _filter = 
    INTERSECT(
        CALCULATETABLE(VALUES('Table'[Customer]),'Table'[Year] = 2021),
        CALCULATETABLE(VALUES('Table'[Customer]),'Table'[Year] = 2022)
    )
    RETURN
    CALCULATE(
        SUM('Table'[Price]),
        'Table'[Year] = 2021,
        _filter
    )

     





          

    Showcase Report – Contoso By SpartaBI

10 Replies