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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Solution Authors