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

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

Reply
Anonymous
Not applicable

Calculate not filtering

Hi,

 

I have the following three tables:

  • calendar
  • sales
  • salesstaff

I built a table, where I try to filter for the Top X sales staff based on a slicer. 

 

To rank the staff I use the following measure: 

 

Rank = RANKX(ALLSELECTED(DimSalesStaff),CALCULATE(SUM('Sales'[Sale])),,DESC,Dense)

 

To then show the revenue on for the Top X staff, I use the following measure:

 

Sales = 
var TopX = SELECTEDVALUE('Top X'[Top X])
Return
CALCULATE(SUM('Sales'[Sale]),FILTER('Sales', [Rank]<= 10))

 

However, the rank filter is not working. Any suggestion on how I can fix this?

 

Thanks

 

1 ACCEPTED SOLUTION

HI @Anonymous ,

 

Can you please refer following blog that I wrote some time back to display number of selected rows in a table for a selected Category on Total sales:

https://community.powerbi.com/t5/Community-Blog/Controlling-Number-of-Rows-to-Be-Displayed-in-a-Table-Visual/ba-p/1317661

 

I think this is what you are looking for.

 

Let me know if this helps.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

It seems like you want to calculate the sum of Sales based on dynamic  slicer value for Top N.

You could use the following formula:

Rank =
RANKX (
    ALLSELECTED ( Sales ),
    CALCULATE ( SUM ( 'Sales'[Sale] ) ),
    ,
    DESC,
    DENSE
)
filterTopN =
VAR _select = MAX ( forSlicer[value] ) RETURN IF ( [Rank] <= _select, 1, 0 )
total =
VAR _select =
    MAX ( forSlicer[value] )
RETURN
    CALCULATE ( SUM ( Sales[Sale] ), FILTER ( ALL ( Sales ), [Rank] <= _select ) )

My visualization looks like this:

8.31.1.1.PNG

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

Anonymous
Not applicable

@Anonymous @Pragati11 Thanks for your feedback.

 

However, neither of your solutions fixed my problem. I have attached a link to test file. Could you please have a look at this and tell me why my sales measure is not working correctly?

 

Thanks!

HI @Anonymous ,

 

Can you please refer following blog that I wrote some time back to display number of selected rows in a table for a selected Category on Total sales:

https://community.powerbi.com/t5/Community-Blog/Controlling-Number-of-Rows-to-Be-Displayed-in-a-Table-Visual/ba-p/1317661

 

I think this is what you are looking for.

 

Let me know if this helps.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

Thanks for sharing @Pragati11 This is very helpful!

Pragati11
Super User
Super User

Hi @Anonymous ,

 

Can you try modifying your RANKX calculation as follows:

 

TotalSales = CALCULATE(SUM('Sales'[Sale]))

Rank = RANKX(ALLSELECTED(DimSalesStaff),TotalSales,,DESC,Dense)

 

As you are creating a ranking measure, try above way and see if the ranks work now.

Also, share screesnhot around what ranks you are getting.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.