Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I'm new to PowerBI and need to create a PieChart based on a subset of a table, the subset contains only those rows that belong to one of the top 10 most occuring items with a certain value in said table.
In SQL it would be something like this:
Measure = myValue IN ( SELECT myValue FROM myTable WHERE myValue in ( SELECT TOP 10 myValue, COUNT(1) as counter FROM myTable WHERE filterValue = 1 GROUP BY myValue ORDER BY counter DESC ) )
How do I translate this problem with a measure with DAX/PowerBI?
I know it's not very effective to use a measure for this (recalculating the top 10 for every row..), but I don't have access to the database or PowerQuery so unless I'm missing an other alternative the measure is the only way.
I've been trying to use the summarize and filter functions, but everything I try leads to errors and undesired results. Any help would be appreciated!
Solved! Go to Solution.
hi, @Anonymous
There is a simple way for you refer to:
Use RANKX Function to create a measure like this:
Rank = RANKX(ALLSELECTED(Table1),CALCULATE(COUNTA(Table1[myValue])),,DESC )
or
Rank = RANKX(ALLSELECTED(Table1),CALCULATE(COUNTA(Table1[myValue]),filter(Table1, Table1[filterValue]=1)),,DESC )
Then drag it into visual level filter and set is less then or equal to 10
Result:
Best Regards,
Lin
hi, @Anonymous
There is a simple way for you refer to:
Use RANKX Function to create a measure like this:
Rank = RANKX(ALLSELECTED(Table1),CALCULATE(COUNTA(Table1[myValue])),,DESC )
or
Rank = RANKX(ALLSELECTED(Table1),CALCULATE(COUNTA(Table1[myValue]),filter(Table1, Table1[filterValue]=1)),,DESC )
Then drag it into visual level filter and set is less then or equal to 10
Result:
Best Regards,
Lin
Why you don't have access to power query? Are you working in direct query?
A third party destributes the data to us via Azure, but they blocked it so we cannot use those functionalities sadly.
Can you use Calculated table (new table on top banner)?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |