cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jplanellvCLNT
New Member

Summarize categories of different columns

Hi everyone, I have two columns with product categories... Each column have their own measure (in this case produced tons)... I need to summarize the content of both category columns and show the Sum for each category... In Excel it´s easy  using "IF" but I don´t find the right way to do this in Power BI...

jplanellvCLNT_0-1617994798872.png

this is the summary of the previous image, in this case I need to calculate the sum of MT + MT keeping the categories... My expected result its have Clarsil = 92 MT

 

jplanellvCLNT_1-1617994854350.png

I appreciatte your support.

 

1 ACCEPTED SOLUTION
MisterFry
Resolver I
Resolver I

I'd approach it like this: 

MT Total = 
VAR thisProduct = SELECTEDVALUE(<your first product field>) RETURN
VAR excessTons = CALCULATE(SUM(<excess tons field>, ALL(<first product field>), <second product field> = thisProduct)) RETURN
SUM(MT) + excessTons

 

This formula relies on the filter context of your second matrix table to find the indicated product, and apply that product filter to your second field (while ignoring what's in the first) and add the two sums together. 

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@jplanellvCLNT 

I am not sure what is the dax for this MT_Exc measure, however you could just add another expression to it.

 

MT_Exc = (current expression) + calculate(sum([MT]), filter(table,[Product]="CLARSIL"))

 

If not working please share your formula for the MT_Exc measure.

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

MisterFry
Resolver I
Resolver I

I'd approach it like this: 

MT Total = 
VAR thisProduct = SELECTEDVALUE(<your first product field>) RETURN
VAR excessTons = CALCULATE(SUM(<excess tons field>, ALL(<first product field>), <second product field> = thisProduct)) RETURN
SUM(MT) + excessTons

 

This formula relies on the filter context of your second matrix table to find the indicated product, and apply that product filter to your second field (while ignoring what's in the first) and add the two sums together. 

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!