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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Joepower
Frequent Visitor

Select number of TopN of a calculated table per slicer

is there a way to select topn of a calculated table by slicer?

3 REPLIES 3
lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

1. I have 2 tables from Excel (toptop.xlsx, topn.xlsx).

2. toptop.xlsx delivers data to calculate the topn of it selected; topn selected from the excel topn.xlsc (1 to 10).

3. My Dax-code is a calculated table to return the ranked topn-list.

4. is it possible to make a slicer, so the user can select the number of topN?

 

The result should be looking like:

 Screenshot 2023-08-28 052209.png

 

 

TabelleTopN = 

    VAR TopNTabelle =
        SUMMARIZE(
            TOPN(
                SelectionValue,
                SUMMARIZE(
                    DeineTabelle,
                    DeineTabelle[Land],
                    "Anzahl",
                    DISTINCTCOUNT(
                        DeineTabelle[ID]
                    )
                ),
                [Anzahl], DESC
            ),
            DeineTabelle[Land],
            "Anzahl",
            DISTINCTCOUNT(
                DeineTabelle[ID]
            )
        )

    VAR TopNTabelleRang =
    ADDCOLUMNS(
        TopNTabelle,
        "Rang",
        RANKX(
            TopNTabelle,
            [Anzahl],
            [Anzahl], DESC
        )
    )

RETURN TopNTabelleRang

 

 

SelectionValue
1
2
3
4
5
6
7
8
9
10

 

LandID
Australien55
Australien56
Australien57
Australien58
Australien59
Australien60
Australien61
Australien62
Australien63
Australien64
China66
China95
China11
Deutschland34
Deutschland19
Deutschland44
Deutschland63
Großbritannien50
Spanien45
Spanien89
Spanien14
Spanien33
Spanien67
USA1
USA2
USA3
USA4
USA5
USA6
USA7
USA8
USA9
USA10
USA11
USA12
USA13
USA14
USA15
USA16
USA17
USA18
USA19
USA20
USA21
USA22
USA23
USA24
USA25
USA26
USA27
USA28
USA29
USA30
Nigeria77
Nigeria78
Nigeria79
Nigeria80
Nigeria81
Nigeria82
Nigeria83
Nigeria84
Nigeria85
Nigeria86
Kolumbien55
Kolumbien56
Kolumbien57
Kolumbien58

Yes, that is possible. There are some nuances, they are well described in this article: Use of RANKX in Power BI measures - SQLBI

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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