Reply
tecumseh
Resolver II
Resolver II
Partially syndicated - Outbound

TopN Returns Blank Calculated Table

Hi all,

I am trying to return a Calculated Table with TopN where user selects the N from a Slicer disconnected table of values

[Get SelectedN] then returns what the user selected from the slicer.

What am I doing wrong?

Top Sales for N =
    TOPN([Get Seleted N],
    SUMMARIZE(
        sales_performance,
        sales_performance[first_name],
        "Total Sales", SUM(sales_performance[Sales])
    ),
    [Total Sales], DESC
    )
 
Thanks,
-w
1 ACCEPTED SOLUTION

Syndicated - Outbound

Got it working with help from Gilbert Quevauvilliers in this article

My final DAX:

TopN Sales Person =
VAR __SelectedTop = SELECTEDVALUE(N_Values[NValues])
RETURN
SWITCH(
    TRUE(),
    __SelectedTop =0, [Total Sales],
    RANKX (
        ALLSELECTED(sales_performance[first_name] ),
        [Total Sales]
    )
    <= __SelectedTop,
    [Total Sales]
)

View solution in original post

2 REPLIES 2
tecumseh
Resolver II
Resolver II

Syndicated - Outbound

I fixed my model and my DAX and this does work:

Top Sales for N =
 TOPN(10,
    SUMMARIZE(
        dimSalesPeople,
        dimSalesPeople[first_name],
        "Total Sales", SUM(sales_performance[Sales])
    ),
    [Total Sales],DESC
 )
 
Seems my problem is with my SELECTEDVALUE, I tried:
Get Seleted N =
VAR __NValue = SELECTEDVALUE(N_Values[NValues])
RETURN
    DIVIDE( __NValue,1, "There is an error" )

But my calculated table is still blank.
 
Thanks,
-w

Syndicated - Outbound

Got it working with help from Gilbert Quevauvilliers in this article

My final DAX:

TopN Sales Person =
VAR __SelectedTop = SELECTEDVALUE(N_Values[NValues])
RETURN
SWITCH(
    TRUE(),
    __SelectedTop =0, [Total Sales],
    RANKX (
        ALLSELECTED(sales_performance[first_name] ),
        [Total Sales]
    )
    <= __SelectedTop,
    [Total Sales]
)
avatar user

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)