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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Percentage Issue

Hello exports, 
Here I want the the 5 countries by percantage, but when I did that, it give percet of each country of thr gradn total of this top 5 as you see in right table.
But What I want is to give the 5 countries of grand total for all countries as you see in left table, but I want the top 5 only. What the DAX code to do that?

% issue.png

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Untitled.png

 

Value country: = 
SUM( Data[Value] )

 

Value percent grandtotal: = 
VAR _valueall =
    CALCULATE ( [Value country:], ALL () )
RETURN
    DIVIDE ( [Value country:], _valueall )

 

Top five percent: = 
CALCULATE (
    [Value percent grandtotal:],
    KEEPFILTERS (
        TOPN (
            5,
            ADDCOLUMNS (
                ALL ( Data[Country] ),
                "@valuepercent", [Value percent grandtotal:]
            ),
            [@valuepercent], DESC
        )
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Untitled.png

 

Value country: = 
SUM( Data[Value] )

 

Value percent grandtotal: = 
VAR _valueall =
    CALCULATE ( [Value country:], ALL () )
RETURN
    DIVIDE ( [Value country:], _valueall )

 

Top five percent: = 
CALCULATE (
    [Value percent grandtotal:],
    KEEPFILTERS (
        TOPN (
            5,
            ADDCOLUMNS (
                ALL ( Data[Country] ),
                "@valuepercent", [Value percent grandtotal:]
            ),
            [@valuepercent], DESC
        )
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Good Work Mr. Jihwan.

but I am not understad the line I highlited. How I can made in my measure>>

 

 

WhatsApp Image 2022-06-19 at 12.04.21 PM.jpeg

@Anonymous 

This is a name given to a virtual column created by ADDCOLUMNS  therefore just type it as is

Hi,

Sorry that I quite do not understand your question.

You can check my attached file, or, please share your sample pbix file's link here, and then I can try to look into it to provide a more accurate solution for your data model.

Thanks.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hello Sir, sorry my data is confidital.

My quesion is what are ( "@valuepercent" and [@valuepercent]) meaning??
my measure is same for you, but I dont know what I mentioned before meaning and how I write in my measure?

 
 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.