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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors