Dynamic % measure with multiple hierarchies in a matrix

I have a matrix with currently 4 rows in a hierarchy to drill down on.

I have crated the following DAX to show the correct % at each level of the hierarchy.
Count No Documents = DIVIDE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
CALCULATE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
ALL(‘223 Key’[223.Doc Name])
)
)

When i try to present this as a % dynamically the % values dont work as while the % breakdown works on the lowest level the higher levels all shows as 100% not a % of their hierarchy as per the 2nd attached picture.

I was able to fix this with the following DAX and show in the first picture.

However i was wondering if there was a more simplistic way to do this and for it to be dynamic if i change items in the hierarchy in the future

% of Docs (Hierarchical) =
SWITCH(
POWER(2,0) * ISFILTERED(‘Vendors Invoices Cockpit’[Country.Country Level 01]) +
POWER(2,1) * ISFILTERED(‘Vendors Invoices Cockpit’[Entity.Entity Level 01])+
POWER(2,2) * ISFILTERED(‘Vendors Invoices Cockpit’[Company code.Company code Level 01]) +
POWER(2,3) * ISFILTERED(‘223 Key’[223.Doc Name]),
1,
DIVIDE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
CALCULATE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
ALL(‘Vendors Invoices Cockpit’[Country.Country Level 01])
)
),
3,
DIVIDE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
CALCULATE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
ALL(
‘Vendors Invoices Cockpit’[Entity.Entity Level 01]
)
)
),
7,
DIVIDE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
CALCULATE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
ALL(
‘Vendors Invoices Cockpit’[Company code.Company code Level 01]
)
)
),
15,
DIVIDE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
CALCULATE(
SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]),
ALL(‘223 Key’[223.Doc Name])
)
),
IF(SUM(‘Vendors Invoices Cockpit’[R.101.Nbr of documents]) >0,“N/A”, BLANK())
)

Hi @alanteal44 , we aim to consistently improve the topics being posted on the forum to help you in getting a strong solution faster. While waiting for a response, here are some tips so you can get the most out of the forum and other Enterprise DNA resources.

  • Use the forum search to discover if your query has been asked before by another member.
  • When posting a topic with formula make sure that it is correctly formatted to preformatted text </>.
    image
  • Use the proper category that best describes your topic
  • Provide as much context to a question as possible.
  • Include the masked PBIX file and any other supporting links and details.

I also suggest that you check the forum guideline How To Use The Enterprise DNA Support Forum. Not adhering to it may sometimes cause delay in getting an answer.

Please also check the How To Mask Sensitive Data thread for some tips on how to mask your pbix file.

Hi @alanteal44, we’ve noticed that no response has been received from you since the 16th of January. We are waiting for the masked demo pbix file .

This will help other users and experts to answer your inquiry better. In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved.

Please find attached the PBIX example file for this issue. The original issue is on the first tab Stats. The Dax is sowing on the Duplicate of stats tab using the measure % of Docs (Hierarchical). As i say this is not dynamic as you change the Hierarchy
F051 Anonomised Final.pbix (162.1 KB)

Hi @alanteal44

I have looked into the file and approach looks fine. Infact I can use something similar :slight_smile:

Other option to calculate different values in Hierarchies in Matrix is to use ISINSCOPE DAX measure. You can get multiple examples in this forum.

Not sure what you mean by “As i say this is not dynamic as you change the Hierarchy”. If you are saying based on Slicer, then try using ALLSELECTED instead of ALL in measure.

Thanks
Ankit J

1 Like

Hi @alanteal44, did the response provided by @Ankit help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark as solution the answer that solved your query. Thanks!

@ankit Thanks for your response.

What i mean is that if a new item(s) get added to the hierarchy i would have to change the DAX to include it. I was looking to see if there is a way to do this dynmically so as the hierarchy changes or if its different in different visuals i can use the same DAX

Hi @alanteal44

DAX works on Contexts.As soon as you make changes in Visuals context changes and evaluation will provide different results. Also, there is no possible way to make DAX measure formula dynamic using Parameters.

Hence, whenever you add/remove hierarchies from Matrix a new DAX formula will be required. Hope this helps in clarifying.

Thanks
Ankit J

1 Like

Hi @alanteal44, did the response provided by @ankit help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark as solution the answer that solved your query. Thanks!

Hi @alanteal44, we’ve noticed that no response has been received from you since the 4th of February. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!

Hi @alanteal44, a response on this post has been tagged as “Solution”. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the check box.

Also, we’ve recently launched the Enterprise DNA Forum User Experience Survey, please feel free to answer it and give your insights on how we can further improve the Support forum. Thanks!