The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
Is there a way of pre-filtering a table before the Top n filter applies?
Scenario: I have a list of companies with sales data. I want to show the bottom n companies rated by Gross Margin, filtered with Sales above a certain limit. If I simply apply both those filters at the visualization level then, regardless of the order that I put them in in the panel, it always applies the Top n filter first and then the other filter second. The consequence of that is that it first produces a list of n and then further reduces that list according the second filter. So, instead of a bottom 5, say, I end up with, say 2. What I want is the bottom n companies out of all the companies that meet the second criteria.
Here's some dummy data:
Customer | Sales ($) |
Customer #009 | 1,500 |
Customer #006 | 6,100 |
Customer #003 | 7,300 |
Customer #008 | 58,500 |
Customer #004 | 102,200 |
Customer #010 | 142,300 |
Customer #007 | 183,000 |
Customer #001 | 199,000 |
Customer #005 | 203,400 |
Customer #002 | 246,000 |
Let's say I want to show the bottom 5 customers by sales with sales above $10,000, this is what I would want to see:
Customer | Sales ($) |
Customer #008 | 58,500 |
Customer #004 | 102,200 |
Customer #010 | 142,300 |
Customer #007 | 183,000 |
Customer #001 | 199,000 |
Ideally, I'd like to be able to do that at the visualization level rather than creating new columns in the data table.
Thanks
@Stuki , assume sales is measure create a new measure use numeric parameter if need
GT 10k =sumx(Values(Customer[Customer]) , if([sales]>10000, [sales], blank()) )
then have topn sales measure
sumx(keepfilterS(TOPN(5, ALLSELECTED(Customer[Customer]) , [GT 10k], asc)), [GT 10k])
TOPN with Numeric Parameter -https://youtu.be/cN8AO3_vmlY?t=26448
Learn Power BI: Dynamic TOPN using TOPN/Window and Numeric parameter: https://youtu.be/vm2mdEioQPQ
Thanks @amitchandak .
I'm going to need some time to fully understand this. I'm pretty new to Power BI so still on the learning curve when it comes to DAX. I have made an attempt to put this into my model and the GT 10k measure is working as it should (ie. returning a blank for any customer with sales < 10k). However, the 2nd measure doesn't return anything. This is what I have entered for it (I have changed the names of the measures so that are consistent with my naming convention):
User | Count |
---|---|
86 | |
84 | |
36 | |
34 | |
34 |
User | Count |
---|---|
94 | |
79 | |
65 | |
55 | |
52 |