Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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?