Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all,
I am trying to do a percentage of parent calculation which is fine but I am using field parameters so users can dynamically change the row selections in a matrix. If the rows are selected in a specific order then the calculation works fine but if they are selected out of order with the switch calculation then the wrong result is returned. I created a dummy table to represent my issue where there are 3 categories, brand, group and country.
DAX formula is:
So my question is, how can I get it to select the correct VAR regardless of the order the field parameters are selected?
Dummy table I created here:
Brand | Group | Country | Value |
Brand1 | Group1 | GB | 37 |
Brand2 | Group1 | GB | 16 |
Brand3 | Group2 | GB | 16 |
Brand4 | Group2 | GB | 21 |
Brand5 | Group2 | GB | 21 |
Brand6 | Group3 | GB | 47 |
Brand7 | Group3 | GB | 41 |
Brand8 | Group3 | GB | 24 |
Brand9 | Group3 | GB | 25 |
Brand1 | Group1 | FR | 21 |
Brand2 | Group1 | FR | 49 |
Brand3 | Group2 | FR | 41 |
Brand4 | Group2 | FR | 22 |
Brand5 | Group2 | FR | 19 |
Brand6 | Group3 | FR | 37 |
Brand7 | Group3 | FR | 27 |
Brand8 | Group3 | FR | 16 |
Brand9 | Group3 | FR | 37 |
Brand1 | Group1 | DE | 9 |
Brand2 | Group1 | DE | 31 |
Brand3 | Group2 | DE | 17 |
Brand4 | Group2 | DE | 21 |
Brand5 | Group2 | DE | 50 |
Brand6 | Group3 | DE | 49 |
Brand7 | Group3 | DE | 33 |
Brand8 | Group3 | DE | 34 |
Brand9 | Group3 | DE | 40 |
**bleep**! I have encountered the same scenario. when i found this post , i hurriedly scrolled down thinking some good soul would have already provided solution 😀.
My post for help: Same problem as the one in this post, but more complicated.
Well, times have changed. Not a problem any more with Visual Calculations
Fascinating issue. Your problem is that the SWITCH() statement exits once it finds a match, and you have to hard code the order it checks in.
In this scenario [Group] loses out because it comes last.
if you put it up front then it works again
I am not aware of a way to sense the order in which the field parameters have been selected by the user. It can be shown visually through the Parameter table but -to my knowledge - not probed programmatically.
So you would need to overcome two large hurdles - first, know the order in which parameters were selected, and then, modify the switch statement dynamically.
Power BI Desktop and Service are missing the EVALUATE function, sadly.
EDIT: This might be helpful: Using SELECTEDVALUE with Fields Parameters in Power BI - SQLBI
EDIT 2: No, it's not. It only provides which fields are selected but not the order they were selected in.
Thank you for your effort in looking into this. I think the problem requires too much effort to solve for the benefit. I've reverted to a simpler version that does not give a sum to 100% of the sub-category but always to 100% of the overall total.
I don't think you should mark my post as the solution (as there isn't currently one). I'll see if I can come up with a workaround of sorts. The problem is also that you can add field parameters multiple times to a visual. That would then make the "order of picking" even more ambiguous. Fun stuff!
Alberto confirmed that this is not currently possible.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
8 |