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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
raphazzz
Helper I
Helper I

How to create a measure that shows % filtered by TOP 10 from the Total?

Hello friends,


I have a spreadsheet that has the total number of cancellations as 293 and I have a table that has the top 10 cities with cancelations and the total of the top 10 is 257. I need to create a card that shows 87%.

The table has a TOPN filter. I tried to create a measure with two variables, one counting the total number of rows (293) and another variable with the topN of the same count (like the table).  

It didn't work. Can you guys help me?

raphazzz_1-1675903320411.png

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@raphazzz , Assuming cancels is not a TOPN measure create topn meausre

 

M1= SUMX(keepfilters(topn(10, ALL('Table'[Customer City]) , [Cancels], desc)), [Cancels])

 

M1 % = divide(M1= SUMX(keepfilters(topn(10, ALL('Table'[Customer City]) , [Cancels], desc)), [Cancels]), calculate([Cancels], allselected()) )

 

or

 

M1 % = divide(M1= SUMX(keepfilters(topn(10, ALL('Table'[Customer City]) , [Cancels], desc)), [Cancels]), calculate([Cancels], all()) )

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@raphazzz , Assuming cancels is not a TOPN measure create topn meausre

 

M1= SUMX(keepfilters(topn(10, ALL('Table'[Customer City]) , [Cancels], desc)), [Cancels])

 

M1 % = divide(M1= SUMX(keepfilters(topn(10, ALL('Table'[Customer City]) , [Cancels], desc)), [Cancels]), calculate([Cancels], allselected()) )

 

or

 

M1 % = divide(M1= SUMX(keepfilters(topn(10, ALL('Table'[Customer City]) , [Cancels], desc)), [Cancels]), calculate([Cancels], all()) )

Thanks for your help! I tweaked the second formula a little bit and it's working.

raphazzz_0-1675911042523.png

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.