Forum Discussion
Data aggregation issues for different hierarchical levels
Hi, I am having a hard time dealing with different hierarchical levels within a dataset, if anyone could point me to a solution, I would appreciate.
My dataset (see table bellow) contains scores for variables aggregated in 3 different levels, for one country. Each level 3 variable has a different weight, as indicated on the weight column.
I want to create a graph that will allow me to explore the 3 different levels with the drill down capability. However, my attempts always ended with the wrong data aggregation (ie. PowerBI not taking into account the need to rebalance the weights when moving from one level to another).
To illustrate my issue, an example of what the correct data aggregation would be: if I want to see the score for variable A for country XX, a simple sumproduct (Score*Weight), with the interval of lines 2 to 5 would do the trick. The corresponding score will be 3,10. For variable AB, PowerBI needs to rebalance the weights so that the three corresponding weights (lines 2, 3 and 4) add up to 1, and the correct score would be 2,85. For variable ABA, PowerBI would need to rebalance the two weights (lines 2 and 3) so that they would add to 1 and calculate the corresponding score, which would be 2,27.
Thanks in advance for anyone who can help me
| Country | Variable Level 1 | Variable Level 2 | Variable Level 3 | Weight | Score |
| XX | A | AB | ABA | 0,2 | 1 |
| XX | A | AB | ABA | 0,35 | 3 |
| XX | A | AB | ABC | 0,40 | 4 |
| XX | A | AA | AAA | 0,05 | 5 |
| XX | B | BA | BAA | 0,4 | 0 |
| XX | B | BA | BAB | 0,1 | 1 |
| XX | B | BB | BBA | 0,2 | 6 |
| XX | B | BB | BBA | 0,15 | 2 |
| XX | B | BB | BBC | 0,15 | 3 |
8 Replies
- Ashish_MathurSuper User
Hi,
Your question is not clear. How did you arrive at the figures of 3.10 or 3.00? What do you mean by "rebalance the weights"?
- AnonymousNot applicable
Hi Ashish_Mathur, thanks for your reply!
Let me show you an example of what I am trying to replicate in PowerBI: I want to be able to calculate the weighted score for each variable, given the 3 different levels. For example, the weighted score for variable A (Level 1) will be a simple sumproduct (0,2*1+0,35*3+0,4*4+0,05*5). Now, for variable AB (Level 2), I have to rebalance the weights because they won't add up to 1 (0,2 + 0,35 + 0,4). Once I rebalance the weights, I can do a sumproduct between the 3 new rebalanced weights and the corresponding score, which would be (0,21*1+ 0,37*3 + 0,42*4), giving me a result of 2,85. For a level 3 variable, let's say variable ABA, I would also have to rebalance the weights so they add up to 1 in order to do a sumproduct (0,36*1 + 0,64*3), giving me a result of 2,27.
Please let me know if these examples are not clear.
Thanks for the attention!
- Ashish_MathurSuper User
Hi,
That is exacy what my question is. What logic do we have to use the rebalance the weights from 0.20 to 0.21 etc. Explain that very clearly.
- amitchandakSuper User
Anonymous , not very clear.
Have you tried a measure like
sumX(Table,Table[Score]*Table[Weight])
If need different calculation at different level : https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/