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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
SeGr
Helper I
Helper I

using field parameters as a value in TopN

Hi team,

 

I am using Field Parameters to switch between measures in a stacked chart.

One requirement that I have is to calculate TopN.

My issue is that the field parameters cannot be used as a value in the filters on this visual.

 

SeGr_0-1663149838991.png

 

How can I calculate TopN based on any measure that's being used?

 

Thank you.

Regards!

1 ACCEPTED SOLUTION
SeGr
Helper I
Helper I

I was able to accomplish this by using

switch

    (selectedvalue (measure parameter order),

    0, [ measure 1 ],

    1, [ measure 2 ], 

    etc

)

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

You have to create a new measure. I could solve the problem by creating the measure like this:

 

Measure = SWITCH(SELECTEDVALUE(ParameterTable[Parameter Order]),
    0, [Measure1],
    1, [Measure2]
)
 
Note: You have to use the order of the parameter ([Parameter Order]) as the argument of SELECTEDVALUE function, to use the index (0, 1, 2, ...) of the parameter in SWITH function.
 
For example, if you have a parameter like this:
 
CostRevenue = {
    ("Cost", NAMEOF('Sales'[CostSum]), 0),
    ("Revenue", NAMEOF('Sales'[RevenueSum]), 1)
}
 
The Measure you have to create and use as TopN filter will be:
 
CostRevenueForTopN = SWITCH(SELECTEDVALUE(CostRevenue[CostRevenue Order]),
    0, 'Sales'[CostSum],
    1, 'Sales'[RevenueSum]
)
 
Thanks!

Thanks for your reply, it helped me with an issue of selecting TopN by parameters that applied to many different visuals!

SeGr
Helper I
Helper I

I was able to accomplish this by using

switch

    (selectedvalue (measure parameter order),

    0, [ measure 1 ],

    1, [ measure 2 ], 

    etc

)

I have a question. Do I need to create a new measurement for this? Thank you.

Anonymous
Not applicable

Hi @SeGr , 

Have you resolved the  issue now?  If so, please kindly  mark your answer as a solution to close the case and help more people find the solution.

 

If I have misunderstood your meaning, please provide some sample data without privacy information and your desired output with more details.

 

 

Best Regards

Community Support Team _ Polly

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.