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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Ratio including a sum with a subtotal

Hi,

 

I have difficulties to calculate ratio including a sum with a subtotal

Based on the example below (table "customer") I need to create a matrix table with Path and x/y as rows and calulated results in columns

 

         

Path       x/yStep     Nb CusInc        Color
Ax1 34Blue
Ay1 91Black
Bx2 83Red
By2 61Green
Cx2 75White
Cy2 71Purple
Dx2 99Black
Dy2 84Red
Ax166 Blue
Ay132 Black
Bx212 Red
By222 Green
Cx279 White
Cy297 Purple
Dx233 Black
Dy226 Red

 

First and seconds columns are the sum for number of customer and income. No problem here

 

For the other calculations, I need to divide the total (sum Inc) by the sum NbCus when step = 1. For now I only have results where path equals A but I need to use the results (66+32) for other Path as well

I will also need to be able to filters(by color and other variables available)  in my report and this matrix

I think I need to use the allexcept function but have difficulties to understand how. Any suggestion ?

 

 

3 REPLIES 3
Anonymous
Not applicable

 Thanks for the answer but this solution does not select the sum(Nb cus) where step = 1 and apply this results as divider for any Path, x/y and step combination. The provided answer only works for the first 2 rows but not after. For example for the third row, I need to be able to create the formula 83/(66+32). Did I miss something?

Anonymous
Not applicable

Works fine with 2 measures:

ZZM_SumNBCust = CALCULATE(SUM(data[Nb Cus]), ALL(data), data[Step] = 1")
 
ZZM_SumIncDivided = SUM(data[Inc]) / [ZZM_SumNBCust]
 
 
My problem now is that those results will not be able to be modified if I select values from different slicers. Any idea how to take slicers results into account with those calculation ?
v-chuncz-msft
Community Support
Community Support

@Anonymous ,

 

Just try to add a measure.

Measure =
DIVIDE ( SUM ( Table1[Inc] ), SUM ( Table1[Nb Cus] ) )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.