cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Periksson Frequent Visitor
Frequent Visitor

Dynamic TOPN problem default value

Ok, so I'm struggling for a few days already to dynamically select top N of my Goods table. The problem is not for selecting top N, but the default value when none is selected. I want it to give me the whole table of Goods when none of N is selected, that is when All is selected on the slicer. I've imitated the steps for the succesful implementation of topN that can be found on many how to videos and tutorials that are very similar or the same.

Here are my measures:

Goods Rank = RANKX(ALL(Goods); [Profit]) 

Profit Top N Goods = CALCULATE([Profit]; TOPN([Selected N]; Goods; [Profit]; DESC; Goods[ID]))

Selected N = SELECTEDVALUE('TopNGoods'[Select N]; COUNTROWS(Goods))

Goods Rank within Selected N = IF([Goods Rank] <= [Selected N]; 1; 0)

The problem is in the Selected N measure specifically if I'm not wrong. When none is selected the measure gives me back 1. So the default value of that measure is 1. And my default value should be the measure of COUNTROWS(Goods). That table doesn't have only one row, but multiple, and it gives me back value 1 when i test it in a table. How is that even remotely possible? What am I doing wrong here?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Dynamic TOPN problem default value

Selected N = SELECTEDVALUE('TopNGoods'[Select N]; COUNTROWS(ALL(Goods)))

But I think you should just create measure(s) with some SWITCH logic.

 

Best

Darek

1 REPLY 1
Super User
Super User

Re: Dynamic TOPN problem default value

Selected N = SELECTEDVALUE('TopNGoods'[Select N]; COUNTROWS(ALL(Goods)))

But I think you should just create measure(s) with some SWITCH logic.

 

Best

Darek

Helpful resources

Announcements
Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 294 members 3,578 guests
Please welcome our newest community members: