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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Sudharsanan
Helper III
Helper III

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!!

Sudharsanan_0-1658922083936.png

 

1 ACCEPTED SOLUTION

@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
)

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

10 REPLIES 10
Sudharsanan
Helper III
Helper III

@SpartaBI i need 25+35+45 from 2021 alone

@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
)

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

@SpartaBI   I am getting the below error and not able to get the answer..can you help me with it?

@Sudharsanan you didn't share the screenshot or I can't see it for some reason

am sorry @SpartaBI  the error is not showing now which was related to values..somehow i fixed it..but the result is blank now

 

@Sudharsanan hey friend, will be back to desk in few minutes. Do you want to do a quick zoom?

@SpartaBI thats should be better..let me know how can i connect?

@SpartaBI meet.google.com/kbh-uyud-dvz

 

SpartaBI
Community Champion
Community Champion

@Sudharsanan what is the result you want to get in the measure?
25 + 35 + 45 ? or also the valus from 2022? 5, 10 and 20?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors