cancel
Showing results for
Did you mean:
Post Patron

## Decomposition tree percentages based on first value

Hi all,

I'm struggling getting the decomposition tree to do what I want.  I'm currently looking at this example:

You see here that the percentages in plaza are based on the total, which is set to 100%. The categories however, are also based on the first measure, so when you add up all the category percentages, you would get the plaza percentage, instead of 100%

Does anyone know if it is possible to make every step in the tree use 100% as it's base? Maybe using a particular DAX measure?

All thelp is appreciated!

Jaap

1 ACCEPTED SOLUTION
Community Support

I find a solution for you:

Instead of creating calculated columns,you can create a measure:

``````Measure 2 =
IF (
HASONEFILTER ( 'Table'[category] ),
COUNT ( 'Table'[measure] )
/ CALCULATE ( COUNT ( 'Table'[measure] ), ALLEXCEPT ( 'Table', 'Table'[Plaza] ) ),
COUNT ( 'Table'[measure] )
/ CALCULATE ( COUNT ( 'Table'[measure] ), ALL ( 'Table' ) )
)``````

Put measure 2 in the "Analyze" filed, and "plaza" and "category" in the "explain by":

Remember to set measure 2 as percentage:

Finally you will see:

For the related .pbix file,pls click here.

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

7 REPLIES 7
Frequent Visitor

Great solution . Can you help me with writing a measure using the If condition and the Hasonefilter functions to create the dax measure for 4 EXPLAINED VARIABLES? Thank you

New Member

referring the example from your question  can you tell me how you are able to show the exact % value . as if I have data as 70% always on decomposition tree it shows as 0.7. I want it to appear as 70% not happening. can anyone give me solution. I have already set the data type as decimal nd formating as percentage.

Post Patron

Hey @manishak I think all I did was use the "Show value as" -> "Percent of grand total" when clicking the drop down on your measure. Not sure if that will work for what you are creating...

Community Support

Based on my research, it cant be realized currently. Logically,"category" is the child node of "plaza",so the total should be the plaza percentage.

Here I have a workaround for you：

Create 2 calculated columns using  dax expressions such as below:

``combine = 'Table'[Plaza]&"-"&'Table'[category]``
``Percentage = FORMAT(CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[combine]))/CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Plaza])),"percent")``

And you will see:

The value I marked in red line is the one you wanna get.

Here is a sample data you can refer to.

If the workaround cant fulfill what you need, you can come up with a new idea and add your comments there to make this feature coming sooner.

https://ideas.powerbi.com/forums/265200-power-bi-ideas

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Post Patron

Thanks a lot for thinking along Kelly,

your solution definitely works for my example, but as always, my example is just a fraction of what the report does. I actually have 5 different "explain by" factors that the users can choose, so that would lead me to need 5! of these combination columns. And users should be able to use the decomposition tree freely, so that they can choose their own order (so category to plaza as well as plaza to category).

I think this is just not possible currently, but I wouldn't be surprised if this is still in development.

Again, thanks a lot for your assistance!

Jaap

Community Support

I find a solution for you:

Instead of creating calculated columns,you can create a measure:

``````Measure 2 =
IF (
HASONEFILTER ( 'Table'[category] ),
COUNT ( 'Table'[measure] )
/ CALCULATE ( COUNT ( 'Table'[measure] ), ALLEXCEPT ( 'Table', 'Table'[Plaza] ) ),
COUNT ( 'Table'[measure] )
/ CALCULATE ( COUNT ( 'Table'[measure] ), ALL ( 'Table' ) )
)``````

Put measure 2 in the "Analyze" filed, and "plaza" and "category" in the "explain by":

Remember to set measure 2 as percentage:

Finally you will see:

For the related .pbix file,pls click here.

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Post Patron

Hey Kelly,

Really nice solution! Unfortunately  like I said earlier, in the decomposition tree, one of the cool things is that your end users can determine what order to put the categories in. So they can choose to just take category first, and then plaza. In that case your measure, which works really well in this scenario, would not work in other scenario's.

I'll still accept your solution, because it does work for the example I gave you 🙂

Jaap

Announcements

#### Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group