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
filipebodas
Helper I
Helper I

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
v-jayw-msft
Community Support
Community Support

Hi @filipebodas ,

 

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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.

Hi @filipebodas ,

 

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
VahidDM
Super User
Super User

Hi @filipebodas 

 

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
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.

Top Solution Authors