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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to use multiple Top N Filters!

Hi Everyone!

 

I am new to Power BI and am trying to build a dashboard to show each company's 2022 and 2023 sales data, but the business partner wants me to filter the 2022 and 2023 top 10 companies only! So in this case, if a company is in the top 10 in 2022 but not the top 10 in 2022 it should still show on the dashboard since Power BI does not support multiple Top N Filters is there any way to get what I want? 

Both 2022 and 2023 sales values are measures I created based on the original data set, we have other information such as segments in the data set I also want to make sure that the ranking will work properly when we filter by different segments.

 

I have created a fake dada below just to make more sense!

Untitled.jpg

Thank you so much for your help!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1693549102888.png

2. create a measure with below dax formula

 

Measure =
VAR tmp =
    FILTER ( ALL ( 'Table' ), YEAR ( [Date] ) = 2022 )
VAR tmp1 =
    FILTER ( ALL ( 'Table' ), YEAR ( [Date] ) = 2023 )
VAR _a =
    TOPN ( 2, tmp, [Sale], DESC )
VAR _b =
    TOPN ( 2, tmp1, [Sale], DESC )
VAR _c =
    SELECTCOLUMNS ( _a, "CN", [Company Name] )
VAR _d =
    SELECTCOLUMNS ( _b, "CN", [Company Name] )
VAR _e =
    UNION ( _c, _d )
VAR cur_cn =
    SELECTEDVALUE ( 'Table'[Company Name] )
RETURN
    IF ( cur_cn IN _e, 1 )

 

3. add a table visual with Table fields ,add measure to table visual filter pane and set

vbinbinyumsft_1-1693549415508.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1693549102888.png

2. create a measure with below dax formula

 

Measure =
VAR tmp =
    FILTER ( ALL ( 'Table' ), YEAR ( [Date] ) = 2022 )
VAR tmp1 =
    FILTER ( ALL ( 'Table' ), YEAR ( [Date] ) = 2023 )
VAR _a =
    TOPN ( 2, tmp, [Sale], DESC )
VAR _b =
    TOPN ( 2, tmp1, [Sale], DESC )
VAR _c =
    SELECTCOLUMNS ( _a, "CN", [Company Name] )
VAR _d =
    SELECTCOLUMNS ( _b, "CN", [Company Name] )
VAR _e =
    UNION ( _c, _d )
VAR cur_cn =
    SELECTEDVALUE ( 'Table'[Company Name] )
RETURN
    IF ( cur_cn IN _e, 1 )

 

3. add a table visual with Table fields ,add measure to table visual filter pane and set

vbinbinyumsft_1-1693549415508.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors