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
Anonymous
Not applicable

Percentages over Hierarchies

Hello guys,

 

I would like some help regarding how do you calculate % over hierarchy levels.

 

I have a matrix, which has a the final results but it is missing a litte twist regarding how my months are ordered.

 

filipebodas_0-1637778010222.png

 

This is my solution, here you can see the 2.162 has 98% of 2019's Total and the following percentages as 17,7% of the 98% for august, and so on. 

 

However, when I order my month in my calendar table by month number, the same matrix stays like this:

 

filipebodas_1-1637778153678.png

 

Can someone explain to me why this happens? And if possible, how can I turn this around.

 

As for the DAX measure that calculates the %, I followed this post by Arpita that is really nice: https://medium.com/geekculture/calculating-percentages-over-hierarchies-in-dax-power-bi-chapter-8-c3...

 

% Orders All Levels =

VAR CurrentOrders = [Total Orders]

VAR PenuriasOrders =
     CALCULATE (
     [Total Orders],
     ALLSELECTED('Calendar'[Month Name])
     )

VAR YearOrders =
     CALCULATE (
     [Total Orders],
     ALLSELECTED(Orders[Penúria])
     )

VAR TotalOrders =
     CALCULATE (
     [Total Orders],
     ALLSELECTED('Calendar'[Year])
     )

VAR RatioToParent =
     IF (
     ISINSCOPE ( 'Calendar'[Month Name] ),
     DIVIDE ( CurrentOrders, PenuriasOrders, 0),
     IF (
         ISINSCOPE ( Orders[Penúria]),
         DIVIDE (CurrentOrders, YearOrders, 0),
            IF (
            ISINSCOPE( Calendar[Year] ),
            DIVIDE (CurrentOrders, TotalOrders, 0)
            )))

Return RatioToParent
4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Try using ALLEXCPET() function instead of ALLSELECTED() function.

https://docs.microsoft.com/en-us/dax/allexcept-function-dax 

If it doesn't help, you can check which variable is wrong by returning each variable separately.

 

Best Regards,

Jay

Anonymous
Not applicable

It didn't solve. The strangest thing is that with the Month Number it calculates correctly but if I change the variable from Month Number to Month Name, it gives a different value for the % of the month. But either Month Number and Month Name come from the Calendar Table.

Anonymous
Not applicable

Hi @Anonymous ,

 

Can you share some sample data? It's quite hard to figure out what's wrong in the formula without any data to test.

 

Best Regards,

Jay

VahidDM
Super User
Super User

Hi @Anonymous 

 

Can you post sample data as text and expected output?
Not enough information to go on;

please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
4. Relation between your tables

Appreciate your Kudos!!
LinkedIn:www.linkedin.com/in/vahid-dm/

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.