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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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