cancel
Showing results for
Did you mean:
Frequent Visitor

## 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 8
Super User III

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"?

Regards,
Ashish Mathur
http://www.ashishmathur.com
Super User IV

@thomas_v , 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/

Proud to be a Super User!

Frequent Visitor

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!

Super User III

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.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Frequent Visitor

Hi Ashish_Mathur,

The logic we need to use is the proportionality of the weights within the level we want to calculate the weighted score.

Example: To rebalance the weights for calculting the score for variable AB, the formula is (Weight AB)/(Sum of all Weights for AB):

1. (0,2)/(0,2+0,35+0,40) = 0,21 for the first weight

2. (0,35)/(0,2+0,35+0,40) = 0,37 for the second weight

3. (0,4)/(0,2+0,35+0,40) = 0,42 for the third weight

Super User III

Hi,

Thank you for clarifying.  Can you please also share the exact result you want.  Don't share visual for now.  Just share the expected result in a Table format and let me know what selections in the slicer/filter will you be making.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Frequent Visitor

Please find bellow a table with the expected results. I changed the table so that the levels are now a column. As for the slicers and filters, the only one would be the country column. As for the variables and the levels, my intention is to use the drill down capability to show, initially, only variables from the level 1 and once the user clicks on a varible, it would show the corresponding variables on level 2.

 Country Level Variable Weighted Score XX 1 A 3,1 XX 1 B 2,1 XX 2 AB 3,0 XX 2 AA 5,0 XX 2 BA 0,2 XX 2 BB 3,9 XX 3 ABA 2,3 XX 3 ABC 4,0 XX 3 AAA 5,0 XX 3 BAA 0,0 XX 3 BAB 1,0 XX 3 BBA 4,3 XX 3 BBC 3,0
Super User III

Hi,

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Power Platform Community Conference

Check out the on demand sessions that are available now!

#### Microsoft Power Platform Communities

Check out the Winners!

#### Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors