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
yforti
Helper II
Helper II

Help - Matrix Row Totals

Hi guys!

I have a problem creating a measure that solves the following case:

 

The problem focuses on one measure (% Custo x Pacote) that refers to another (M.C - Oportunidade R$).

Below the definition of each measure:

% Custo x Pacote =DIVIDE([Valor Custo],[Valor Pacote])


M.C - Oportunidade R$ IF([% Custo vs Pacote]<0.3,0,([% Custo vs Pacote]-0.3)*[Valor Pacote])

The purpose of M.C - Oportunidade R$ is to calculate the possible contribution margin for each product that exceeds the 30% limit.

Now the problem definition:
When we look at the second level of the matrix, the calculation is correct, let's see:

For example, the first row of second level is Morumbi:

- This object presents 32.8%, exceeding the limit of 30%, so there is 2.83% left, which represents a contribution M.C - Oportunidade R$ of 4524,98 (marked in yellow). Simple math here: 2,83% represents 4524,98 of 159.868 (marked in black)


Now the problem happens when we look at the first level of the Matrix (marked in red).

As there is a condition in the measure (M.C - Oportunidade R$ IF([% Custo vs Pacote]<0.3,0) , the total is not calculated in the first level, because the measure is below 30%, in this case it is 26% (marked in blue), then the total of the first level is zero (marked in green).

What I need is that the total is the sum of the existing contribution margins, in this case: 

- 4524,98+3993,32+193,77 (marked in pink) = 8712,07

So, the condition of M.C - Oportunidade R$ IF([% Custo vs Pacote]<0.3,0 needs to be maintained, but for the first level of the matrix the calculation needs to be done by summing the margins of the second level.
Capturar.PNG


1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @yforti 

 

Please try this measure: 

Measure = SUMX(VALUES('Table'[Second level]),[M.C - Oportunidade R$])

vjingzhang_1-1654162077321.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @yforti 

 

Please try this measure: 

Measure = SUMX(VALUES('Table'[Second level]),[M.C - Oportunidade R$])

vjingzhang_1-1654162077321.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. I cannot use screenshots of your source data.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

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.