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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
dgilm33
Helper I
Helper I

Dynamic Top N + Other

Hi All,

 

I have created a trending line graph visual, with quarter year and month year in the X-axis, the spend in the Y-axis, and then of course the legend. I also have slicers on the page. I've been asked a few times now to have the visual be "top n + other". To this point I haven't been able to accomplish this. I can't share the data I'm working with, but have created this sample data below. Using this data, I would for example want to be able to show Top 2 + Other in the line graph where it will show Ford and Toyota, with Dodge and Tesla making up the "Other" spend line.

dgilm33_0-1709063395066.pngdgilm33_1-1709063414959.png

 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @dgilm33 

You can refer to the following solution. 

Sample data is the same as yours.

1.Create new table

Type = var a=SUMMARIZE('Table',[Brand])
return UNION(a,{"Other"})

The table has no relationship with the original table.

2.Creat a measure.

MEASURE =
VAR a =
    SUMMARIZE (
        TOPN (
            2,
            SUMMARIZE ( ALLSELECTED ( 'Table' ), [Brand], "Sum", SUM ( 'Table'[Sales] ) ),
            [Sum], DESC
        ),
        [Brand]
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Type'[Brand] ) = "Other",
        CALCULATE ( SUM ( 'Table'[Sales] ), NOT ( 'Table'[Brand] ) IN a ),
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            'Table'[Brand] IN a,
            'Table'[Brand] IN VALUES ( 'Type'[Brand] )
        )
    )

3.Put the following field to visual.

vxinruzhumsft_0-1709100050957.png

Output

vxinruzhumsft_1-1709100062545.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @dgilm33 

You can refer to the following solution. 

Sample data is the same as yours.

1.Create new table

Type = var a=SUMMARIZE('Table',[Brand])
return UNION(a,{"Other"})

The table has no relationship with the original table.

2.Creat a measure.

MEASURE =
VAR a =
    SUMMARIZE (
        TOPN (
            2,
            SUMMARIZE ( ALLSELECTED ( 'Table' ), [Brand], "Sum", SUM ( 'Table'[Sales] ) ),
            [Sum], DESC
        ),
        [Brand]
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Type'[Brand] ) = "Other",
        CALCULATE ( SUM ( 'Table'[Sales] ), NOT ( 'Table'[Brand] ) IN a ),
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            'Table'[Brand] IN a,
            'Table'[Brand] IN VALUES ( 'Type'[Brand] )
        )
    )

3.Put the following field to visual.

vxinruzhumsft_0-1709100050957.png

Output

vxinruzhumsft_1-1709100062545.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.