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

Top/Bottom N on a single chart with field parameters

Hi guys!

I have the following bar chart where the users are able to switch between two measures, Numeric and Percentage measure. 
Now on this tail analysis visual, I have hundreds of ids that go from the best to the worst, given what measure is selected. 

Meeskass_0-1718049891446.png


My users have now a requirement to add a Top/Bottom N button on the report, so that they can simply visually see both top/bottom 10 ids on the bar chart, given what measure is selected. 

On paper it sounds relatively easy, but I am unable to produce such thing via DAX at the moment. 
Has anyone had a similira requirement in the past? How did you solve it? 

Thanks a bunch!

2 REPLIES 2
Meeskass
Helper I
Helper I

Hey Jayleny,

I will give it a try but I am not sure whether it is 100% the output I'm looking. 
I'd like to see Top/Bottom N on the bar chart at the same time. So they're both there, both sides of the tail, comparable to each-other. 

I'll try with parameter and dynamic measure tho 👌

v-jialongy-msft
Community Support
Community Support

Hi @Meeskass 

 

First, you'll need to create a parameter that allows users to choose between viewing the Top N or Bottom N items. 

vjialongymsft_0-1718073578877.png

 

 

Next, you'll create a dynamic measure that responds to the parameter and switches between your top/buttom10 measures based on user selection.

Dynamic Measure = 
VAR SelectedMeasure = [Your Measure Switch Logic Here]
VAR TopBottomValue = SELECTEDVALUE('TopBottomN'[Value], 0)
RETURN
IF(
    TopBottomValue = 0,
    SelectedMeasure,
    IF(
        TopBottomValue > 0,
        TOPN(TopBottomValue, ALL('YourTable'[ID]), SelectedMeasure, DESC),
        TOPN(ABS(TopBottomValue), ALL('YourTable'[ID]), SelectedMeasure, ASC)
    )
)

 

 

 

 

 

Best Regards,

Jayleny

 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.