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
Vahks
Helper I
Helper I

Dynamics TopN filtered by an other column

Hello,

 

I'm trying to find a solution but nothing helps me.

 

So, I would like to have a dynamic topN which brings together the following list of artists :

 

Vahks_0-1701881085274.png

This is correctly filtered when i use this slicer :

Vahks_1-1701881292483.png

 

With these measures  :

 

Tickets = IF([Rank Artist] <= [TopN Value], [Sum_Tickets])

 

 

 

Sum_Tickets = SUM(Events[Ticket_Sold])

 

 

 

Rank Artist = RANKX(
       ALL(PollStar_events_FilteredSearch[Artist_Name]),
       [Tickets], , DESC, Dense)

 

 

The table of artists changes if I take the topN as follows:

Vahks_2-1701881483998.png

But I want to keep the top 10 artists and filter it according to the list of systems below: (i have to hide the system names, but you can call it System 1, System 2, etc..) :

Capture d'écran 2023-12-06 175300.jpg

 

But when I move the TopN cursor, it doesn't work and it keeps the number of tickets for all the artists whether or not they are part of the TopN entered.

 

Does anyone have an idea how I could achieve this result please ?

If I'm not clear, don't hesitate to ask me for more information.

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Vahks try this measure, and here is the visual:

 

TopN Tickets = 
VAR __TopN = 5  --replace this value of 5 with your TopN selected value
VAR __RankTableByArtist = 
    ADDCOLUMNS ( 
        ALLSELECTED ( 'DataTable'[Artist_Name] ), 
        "@Rank", 
            CALCULATE ( 
                RANKX ( ALLSELECTED ( 'DataTable'[Artist_Name]  ), [Sum Tickets], , DESC ), 
                REMOVEFILTERS ( 'DataTable'[System] ) 
            ) 
    ) 
VAR __FilterTopN = FILTER ( __RankTableByArtist, [@Rank] <= __TopN ) 
RETURN
CALCULATE ( 
    [Sum Tickets], 
    KEEPFILTERS ( __FilterTopN ) 
)

 

Result based on Top 5

 

parry2k_0-1701902099081.png

 

Result based on Top 7

 

parry2k_1-1701902139992.png

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@Vahks I have no idea what you are doing here. The measure you shared is not the same as what I sent, so not going to look into it until you follow the instructions as mentioned. Thanks!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2kSorry, now it's work, i have an other filter which created problem, now your solution work perfectly, thank very much !

parry2k
Super User
Super User

@Vahks and Sum Tickets is just a measure:

 

Sum Tickets = SUM ( 'DataTable'[Tickets] )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Vahks try this measure, and here is the visual:

 

TopN Tickets = 
VAR __TopN = 5  --replace this value of 5 with your TopN selected value
VAR __RankTableByArtist = 
    ADDCOLUMNS ( 
        ALLSELECTED ( 'DataTable'[Artist_Name] ), 
        "@Rank", 
            CALCULATE ( 
                RANKX ( ALLSELECTED ( 'DataTable'[Artist_Name]  ), [Sum Tickets], , DESC ), 
                REMOVEFILTERS ( 'DataTable'[System] ) 
            ) 
    ) 
VAR __FilterTopN = FILTER ( __RankTableByArtist, [@Rank] <= __TopN ) 
RETURN
CALCULATE ( 
    [Sum Tickets], 
    KEEPFILTERS ( __FilterTopN ) 
)

 

Result based on Top 5

 

parry2k_0-1701902099081.png

 

Result based on Top 7

 

parry2k_1-1701902139992.png

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you, I think we are close to the result but there is a difference in result and I don't understand why !

When i selected top 2, you can see the TopN Tickets measure have no result :

Capture d'écran 2023-12-06 175300.jpg

When I remove the remove filter from your function

 

VAR __RankTableByArtist = 
    ADDCOLUMNS ( 
        ALLSELECTED ( 'DataTable'[Artist_Name] ), 
        "@Rank", 
            CALCULATE ( 
                RANKX ( ALLSELECTED ( 'DataTable'[Artist_Name]  ), [Sum Tickets], , DESC )
            ) 
    ) 

 

 

The sum is consistent with the ranking of the artists but obviously it no longer filters through the system.

 

Capture d'écran 2023-12-06 175300.jpg

Can I send you my report so you can maybe see better what's going on?

parry2k
Super User
Super User

@Vahks can you clarify what you mean by "systems" column? It is not clear what you are trying to achieve.

 

Do you want to first find out who are top 10 artists and then show all the systems for those artists? What does your model look like? Also, share sample data in the table format with the expected output.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hello @parry2k ,

 

Systems are just sort of a category, I just have a table that could be represented this way, :

Vahks_0-1701900856688.png

 

No I don't need to see the top artists, I only want the sum of tickets belonging to the chosen top artist (it can be the top 10, 20 or 50, etc.) to be placed under the different categories system.

 

example with the data above if i want the top 7 artist by System :

Vahks_1-1701900892326.png

 

Here is in detail where the sum of the Tickets column comes from (I don't need this table, it's just to show what the figures are made of) :

 

Vahks_2-1701900930293.png

example with the data if i want the top 5 artists by system :

Vahks_3-1701900959852.png

 

Rank 6 and 7 are deleted from system amounts 1 and 2 because Artist 1 uses system 1 and artist 2 uses System 2 and are not part of the top 5.

 

hope it's more clearer

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.

Top Solution Authors