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.
Suppose I have a CSV table such as this.
MainUnit SubUnit
A A1
A A2
A A3
B B1
B B2
B B3
B B4
C C1
C C2
D D1
D D2
D D3
My goal is to calculate, for each MainUnit, the % of it's sub unit count considering all sub units. I am aware that I can create a measure such as below,
UnitCount = COUNTA(UnitSubUnit[SubUnit])
and then in the table set it as [ Show value as --> Percent of grand total ] and it will get me the desired percentage.
But that's not quite what I'm looking for. What I want is a 'TotalUnitCount' measure, which will retun 12 in this example for each row in my table. The reason being I want to use the UnitCount and TotalUnitCount elsewhere in my project, including as parts of other measures. Essentially, this is what I'm looking for.
But it appears that if I calculate a measure like this, it will still not actually return the total number of rows, but rather still grouped acording to the row selection.
TotalUnitCount = COUNTROWS(UnitSubUnit)
When I attempted that, what I get is below; both UnitCount and TotalUnitCount return the same value.
I don't want to set a measure like 'TotalUnitCount = 12' hardcoded for two reasons.
Is this a possibility without hardcoding a measure?
Solved! Go to Solution.
@Anonymous
Here are the three measures and it will work when set the page filter as well.
Unit Count = COUNTROWS(table6)
-------------------------------------------
Total unit Count =
CALCULATE(
[Unit Count],
ALLSELECTED(Table6[MainUnit])
)
-------------------------------------------
Percentage =
DIVIDE(
[Unit Count],
[Total unit Count]
)
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Anonymous
Here are the three measures and it will work when set the page filter as well.
Unit Count = COUNTROWS(table6)
-------------------------------------------
Total unit Count =
CALCULATE(
[Unit Count],
ALLSELECTED(Table6[MainUnit])
)
-------------------------------------------
Percentage =
DIVIDE(
[Unit Count],
[Total unit Count]
)
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
This worked, thanks!
So to make sure I understand, the CALCULATE() function sums up UnitCount, across all MainUnit rows available?
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 |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |