Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
bmms
Helper I
Helper I

How to dynamically calculate the percentage for more than one parameter (column)

Hello,

 

i have a chart where i can show one of two fields (country or product) in Y axie and show the respective percentage in X axie.

I created a parameter based in two fields (country or product), then i choose wich field i want to appear in Y axie (using one sclicer).

Finnaly, i have other slicer by year.

 

But, i don't know how to dynamically calculate the percentage because the Y axies can be changed by user and i only can assigned one measure on X axie!

 

Can you help me?

 

I have the follow table:

 

1.JPG

 

The follow parameter:

 

2.JPG

 

Charts (but with wrong values, it is expected to use percentage)

 

5.JPG

 

 

3.JPG4.JPG

 

In addiction, i shared a link for download an example:

https://we.tl/t-X16hFHWDJ5

 

best regards!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @bmms 

 

I cannot download your example, so I create a sample, and you can try the following measure:

 

Measure = SWITCH(TRUE(),SELECTEDVALUE(Parameter[Parameter Order])=1,DIVIDE(SUMX(FILTER(ALL(Sales),[Country]=SELECTEDVALUE(Sales[Country])),[Value]),SUMX(ALL(Sales),[Value])),SELECTEDVALUE(Parameter[Parameter Order])=0,DIVIDE(SUMX(FILTER(ALL(Sales),[Product]=SELECTEDVALUE(Sales[Product])),[Value]),SUMX(ALL(Sales),[Value])),BLANK())

 

Since I don't know exactly what the percentage on your side is looking for, I calculate the percentage of total value for each country/product

 Output:

vxinruzhumsft_0-1670477770778.png

 

vxinruzhumsft_1-1670477770781.png

 

 

 Best Regards,

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @bmms 

 

I cannot download your example, so I create a sample, and you can try the following measure:

 

Measure = SWITCH(TRUE(),SELECTEDVALUE(Parameter[Parameter Order])=1,DIVIDE(SUMX(FILTER(ALL(Sales),[Country]=SELECTEDVALUE(Sales[Country])),[Value]),SUMX(ALL(Sales),[Value])),SELECTEDVALUE(Parameter[Parameter Order])=0,DIVIDE(SUMX(FILTER(ALL(Sales),[Product]=SELECTEDVALUE(Sales[Product])),[Value]),SUMX(ALL(Sales),[Value])),BLANK())

 

Since I don't know exactly what the percentage on your side is looking for, I calculate the percentage of total value for each country/product

 Output:

vxinruzhumsft_0-1670477770778.png

 

vxinruzhumsft_1-1670477770781.png

 

 

 Best Regards,

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello,

 

thanks for your help.

 

I used your measure, but the percentage it is wrong.

For example, If I Select year = 2021 and product = "C", the correct percentage is 15,09%, but using your measure the percentage is 15,29%.

 

1.3.JPG

 

However, I made some changes to the measure, and i got the correct percentage. I just changed "All" for "AllSelected"!!

 

Percentage = SWITCH(
TRUE(),
    SELECTEDVALUE('Product/Country'[Product/Country Order]) = 1, DIVIDE(SUMX(FILTER(ALLSELECTED(Sales), [Country] = SELECTEDVALUE(Sales[Country])),[Value]), SUMX(ALLSELECTED(Sales),[Value])),
    SELECTEDVALUE('Product/Country'[Product/Country Order]) = 0, DIVIDE(SUMX(FILTER(ALLSELECTED(Sales), [Product] = SELECTEDVALUE(Sales[Product])),[Value]), SUMX(ALLSELECTED(Sales),[Value]))
,BLANK()
)
 
Please see the follow pictures
Wrong:
 
1.1.JPG

 

Correct:

 

1.2.JPG

 

Why Is the percentage wrong when i use "All" in measure"?

 

Best Regards

Anonymous
Not applicable

Hi @bmms 

My measure is based on the parameters you gave without taking into account the filter year, and the all() function filters out all filters and is therefore unaffected by the filter

 

Best Regards!

Yolo Zhu

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.