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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

TOP 5 percentage Wrong output in Power BI

Hi Team,

I need TOP 5 Pecentage but its Wrong output

below is my table Name and Amount and I have calculated as GrandTotal but if select TOP 5 its Wrong Out put 2nd table is Output table

NameAmount%GT of Amount
H6021.05%
J5017.54%
I4014.04%
D3010.53%
F3010.53%
C207.02%
G207.02%
B155.26%
A103.51%
E103.51%

 

below is in Power BI out but its Wrong output

NameAmount%GT of Amount
H6028.57%
J5023.81%
I4019.05%
D3014.29%
F3014.29%

 

 

But I am epecting is below out

NameAmount%GT of Amount
H6021.05%
J5017.54%
I4014.04%
D3010.53%
F3010.53%

 

Thanks

Aruna lavi

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , If your % total correct,if so then use top N of rank on that to filter

example

Top 5 City Rank = CALCULATE([% of total],TOPN(10,all(Table[Name]),[% of tota],DESC),VALUES(Geography[Table]))

 

for % of total

divide(sum(Table[Amount]),calculate(sum(Table[Amount]),all(Table)))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
FarhanAhmed
Community Champion
Community Champion

 

If you want to calculate percent with GrandTotal 

 

 

__Amount = CALCULATE(SUM(Subscription[Amount]),ALL(Subscription))

 

% Amount = SUM(Subscription[Amount])/[__Amount]

 

If you want external filters to be applied on your total Calcuation then you need to change your grand total formula to use ALLEXCEPT 

__Amount = CALCULATE(SUM(Subscription[Amount]),ALLEXCEPT(Subscription ,Subscription[UserID]))

 

and use % Amount same formula

 

 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




Anonymous
Not applicable

Hi Farhan,

Thank you replay.

but no lock if select TOP 5 its wrong percentage (if didnt select top N its give good result)

I am used your Measure given good result but its wrong showing after select TOP N

 

I am selecting TOPN in Power BI 

Select Filter panel

then Name expand Filter Type 

Then by values is %Amount 

 

its wrong Percentage

 

please help on this

 

Thanks

Aruna

 

Anonymous
Not applicable

Hi Team,

This  is Bug in Microsoft Power BI.I have tryed multiple ways but cant fixed(when we required %)

 

But I have fixed using sql server query and Powe BI(Both required)

Step 1(Sql server Query):

 query from DB: we create two extra column 1.Percentage and Rank 

Percentage query :CAST(100.0* [Amount] / (SUM([Amount]) OVER (PARTITION BY  h_Date )) AS DECIMAL(10,2)) AS %_Amount

Rank Function from DB:ROW_NUMBER() OVER( PARTITION BY h_Date ORDER BY [Amount] DESC) AS RowNumberRank

 

Step 2(Power BI):

I have create table for TOP N in Power BI below like

Then given Relationship Query dataset and TOP N  dataset(Step 1 and Step 2)

topN.PNG

 

if anybody any clarification please contact me.

Thanks

Shanvitha

Anonymous
Not applicable

Could you put the formula you're using? 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.