cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
tecumseh
Helper I
Helper I

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

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 November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors