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.
Hi,
I am new to Power Bi and I need help with this. I need to display the top N categories with the max count of that group. I cant use rank because I need to find the max grouped by. I wrote what I need in code and what I hope to display on power BI.
I need it to first give me a total count of all category by open date (inner select), then I need to get the top N categories with the most count (couter select).
Ideal SQL:
select top 5 b.cat, b.max_res
from (
select a.Cat, max(result_count) as max_res
from ( select Cat, Open_dt, count([result number]) as result_count from [result] group by Cat, open_dt) a group by a.Cat) b
so far I have
Total_Result = DISTINCTCOUNT([result number])
When ever I use the MAX() I get this argument: The MAX function only accepts a column reference as the argument number 1.
MAX_G = CALCULATE(MAX([Total_Result]), GROUPBY(Query1, Query1[Cat], Query1[Open_dt]))
Then for TopN I get this Issue: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
TOPn = topn(5, Query1, [MAX_G])
Solved! Go to Solution.
Hi @JeanBean,
Could you post your table structures(including table relationships) with some sample data and your expected result, so that we can better assist on the DAX formula needed?
Regards
Hi @JeanBean,
Could you post your table structures(including table relationships) with some sample data and your expected result, so that we can better assist on the DAX formula needed?
Regards
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 |
---|---|
14 | |
2 | |
2 | |
1 | |
1 |