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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ItoDiaz
Helper I
Helper I

Bad calculated ratio at lower level matrix

Hello all, 

I have created this mesure and i'm triying to use it in a matrix, ratio by etablissement and total ratio are right. My problem is that the ratio by department is not calculated in the rigth way. 

In my Matrix "etablissement" is the first level and "departement" my second level. 
See in the picture what I get (left) by département and what I should obtain (right). 

Matrice.png

 

 

 

 

And here my measure, what should I do to correct this? 

My two table have a relationship many to many

 

Thanks in advance

 

Prorata etablissement et departement = 
VAR Etablissement = SELECTEDVALUE('Plan'[ETABLISSEMENT CONSO]) 
VAR Departement = SELECTEDVALUE('Plan'[DEPARTEMENT]) 
VAR CurrentMonth = "202405" -- Remplacez cette valeur par le mois courant si nécessaire 
VAR Numerator = CALCULATE( SUM('Plan '[Nb Heures Catalogue]), ALLSELECTED(FTEHC[AnnesMois]) ) 

VAR DenominatorPerEtablissement = CALCULATE( DISTINCTCOUNT(FTEHC[ID]), FILTER('FTEHC', FTEHC[AnnesMois] = CurrentMonth && 'FTEHC'[Position lieu_2] = Etablissement) ) 

VAR DenominatorPerDepartement = CALCULATE( DISTINCTCOUNT(FTEHC[ID]), FILTER('FTEHC', FTEHC[AnnesMois] = CurrentMonth && 'FTEHC'[Departement OM] = Departement) ) 

VAR DenominatorTotal = CALCULATE( DISTINCTCOUNT(FTEHC[ID]), FILTER('FTEHC', FTEHC[AnnesMois] = CurrentMonth) ) 

RETURN 
SWITCH( 
TRUE(), 
ISINSCOPE('Plan'[ETABLISSEMENT CONSO]), DIVIDE(Numerator, DenominatorPerEtablissement), 
ISINSCOPE('Plan'[DEPARTEMENT]), DIVIDE(Numerator, DenominatorPerDepartement), DIVIDE(Numerator, DenominatorTotal) )

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @ItoDiaz,

It seems like a common issue when the measure expression calculate on the different hierarchy levels.

Have you try to create a variable with summarize function to manually restore the current hierarchy aggregations levels at first? Then you can use iterator function to apply and summary these records.

For detail informations, you can check the greg's blog about measure total level calculation research.

Measure Totals, The Final Word 

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
ItoDiaz
Helper I
Helper I

Hello, 

 

@Anonymous , thank you for your answer. 


I have read Greg's post and I have tried with Sumx, Summarize and  Hasonevalue, nevertheless I didn't find the good solution. 

Anonymous
Not applicable

HI @ItoDiaz,

It seems like a common issue when the measure expression calculate on the different hierarchy levels.

Have you try to create a variable with summarize function to manually restore the current hierarchy aggregations levels at first? Then you can use iterator function to apply and summary these records.

For detail informations, you can check the greg's blog about measure total level calculation research.

Measure Totals, The Final Word 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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