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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tecumseh
Helper II
Helper II

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

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
Helper II
Helper II

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

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]
)

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.