Forum Discussion
Dynamic Aggregation and Visualization of Reporters by row_sum
Hello Dear Power BI Community,
I'm writing this post because, even with ChatGPT, I couldn't solve my problem.
Dataset Example
Let's assume I have the following table:
Reporter Year Count
| 217773 | 2022 | 2 |
| 217773 | 2023 | 1 |
| 217773 | 2024 | 1 |
| 234325 | 2023 | 1 |
| 234325 | 2024 | 2 |
Goal
I want to create a dynamic Power BI visual where:
- X-axis: Sum of Count
- Y-axis: Distinct count of Reporter
The visual should dynamically adjust when filtering Year.
Expected Results
If no filter is applied (all years selected), the visual should show:
- 1 reporter (217773) with 4 counts
- 1 reporter (234325) with 3 counts
like this:
If 2024 is selected:
- 1 reporter (217773) with 1 count
- 1 reporter (234325) with 2 counts
If 2023 is selected:
- 1 reporter (217773) with 1 count
- 1 reporter (234325) with 1 count
If 2023 & 2024 are selected:
- 1 reporter (217773) with 2 counts
- 1 reporter (234325) with 3 counts
Problem
A major issue I identified is that measures cannot be used as an X-axis in Power BI.
How can I solve this issue and make the X-axis dynamic while allowing the filtering of Year?
Any help would be greatly appreciated! 🚀
Cheers
qwertzuiop
Hi qwertzuiop
You will need to materialize the count using a table containing a column of all possible counts.
CountsTable = SELECTCOLUMNS ( GENERATESERIES ( 1, 10, 1 ), "Count", [Value] )Count Materialized = COUNTROWS ( FILTER ( SUMMARIZECOLUMNS ( 'Table'[Reporter], "@value", [Sum of Count] ), [@value] IN VALUES ( CountsTable[Count] ) ) )Please see the attached sample pbix.
Hi,
PBI file attached.
Hope this helps.
2 Replies
- danextianSuper User
Hi qwertzuiop
You will need to materialize the count using a table containing a column of all possible counts.
CountsTable = SELECTCOLUMNS ( GENERATESERIES ( 1, 10, 1 ), "Count", [Value] )Count Materialized = COUNTROWS ( FILTER ( SUMMARIZECOLUMNS ( 'Table'[Reporter], "@value", [Sum of Count] ), [@value] IN VALUES ( CountsTable[Count] ) ) )Please see the attached sample pbix.
- Ashish_MathurSuper User