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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
rpinxt
Impactful Individual
Impactful Individual

Field Parameters and TopN not working

I have a (simple) matrix in which I use Field Parameters to toggle between 2 views.

On both views I want to show only the TopN (say 5) lines.

rpinxt_0-1664790374535.png

As you see this is not working as I have more then 5 lines.

I cannot put the TopN on POM because when i switch to PF Name it will not work for that field.

(also when using it on POM instead of 5 it only shows 4 and there are about 10.... 🤔)

 

So most logic thing to do was put a topn on prmBreakdown as this is the parameter.

But probably because POM (and when chosen PF Name) are on ALL I still get all.

And you cannot remove these filters because they are part of the visual...

 

Does anybody know how to get TopN working when you are using field parameters in a visual?

1 ACCEPTED SOLUTION
rpinxt
Impactful Individual
Impactful Individual

Ok was able to fix it with (for me in this case) a TopN slider and Parameter field.

Had 2 fields, so made 2 ranking fields and combined with the ranking slider I made, made this rankfilter.

RankFilter = IF(
    [Rank] <= RankSlider[RankSlider Value] && [Rank2] <= RankSlider[RankSlider Value] ,
    1,
    0
)
 
So for the visual put that one in the filter and now it works like a charm.
Whatever breakdown from the field parameter I choose rank or rank2 will be active and for both I will get my TopN.

View solution in original post

3 REPLIES 3
rpinxt
Impactful Individual
Impactful Individual

Ok was able to fix it with (for me in this case) a TopN slider and Parameter field.

Had 2 fields, so made 2 ranking fields and combined with the ranking slider I made, made this rankfilter.

RankFilter = IF(
    [Rank] <= RankSlider[RankSlider Value] && [Rank2] <= RankSlider[RankSlider Value] ,
    1,
    0
)
 
So for the visual put that one in the filter and now it works like a charm.
Whatever breakdown from the field parameter I choose rank or rank2 will be active and for both I will get my TopN.
rpinxt
Impactful Individual
Impactful Individual

@amitchandak ok thanks.....

 

But I thought this would be some easy setting kind of thing.

Do you really need to make so many new measures to make a TopN work with Field parameters?? 😮🤔

 

Think it is more efficient to just make two visuals and a variable TopN slider that works on both visuals.....

amitchandak
Super User
Super User

@rpinxt , Refer to my example. I have two Axis columns Brand and Category

 

Created a field parameter
Parameter = {
("Brand", NAMEOF('Item'[Brand]), 0),
("Category", NAMEOF('Item'[Category]), 1)
}

Then created 2 measures


TOP2 Brand = CALCULATE([Net], TOPN(2,ALLSELECTED('Item'[Brand]), [Net],DESC), values('Item'[Brand]))
TOP2 Category = CALCULATE([Net], TOPN(2,ALLSELECTED('Item'[Category]), [Net],DESC), values('Item'[Category]))


The created selected parameter measure

 

Selected Parameter = maxx(filter(Parameter ,Parameter[Parameter Order] = SELECTEDVALUE(Parameter[Parameter Order])), Parameter[Parameter])

 

 

Final topn

TOP N = SWITCH([Selected Parameter], "Brand" ,[TOP2 Brand], [TOP2 Category])

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Top Solution Authors