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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi All,
I think this should be easy, but I'm still learning the ins & outs of DAX and I'm struggling.
I have this unpivoted data, and need to create a bar graph the % of unique students in each grade in each city (grade will be on the legend, city on the slicer). I already have a matrix of the total number of unique students which I achieved easily with DISTINCTCOUNT of IDs, but I'm struggling with the % of unique students by city:
Student ID | Grade | City |
1 | Sophomore | Albany |
1 | Sophomore | Albany |
1 | Sophomore | Albany |
2 | Sophomore | Tallahassee |
3 | Sophomore | Pittsburgh |
4 | Sophomore | Richmond |
5 | Sophomore | Richmond |
6 | Junior | Pittsburgh |
7 | Junior | Tallahassee |
7 | Junior | Tallahassee |
8 | Junior | Richmond |
9 | Junior | Richmond |
10 | Junior | Albany |
10 | Junior | Albany |
11 | Junior | Pittsburgh |
12 | Junior | Tallahassee |
12 | Junior | Tallahassee |
12 | Junior | Tallahassee |
13 | Junior | Albany |
13 | Junior | Albany |
14 | Junior | Pittsburgh |
15 | Junior | Richmond |
16 | Senior | Tallahassee |
17 | Senior | Pittsburgh |
17 | Senior | Pittsburgh |
18 | Senior | Albany |
18 | Senior | Albany |
19 | Senior | Richmond |
20 | Senior | Tallahassee |
21 | Senior | Richmond |
22 | Senior | Albany |
22 | Senior | Albany |
23 | Senior | Richmond |
Thank you to anyone who can help.
Solved! Go to Solution.
Measure =
VAR _num = CALCULATE(DISTINCTCOUNT('Table'[Student ID]),ALLEXCEPT('Table','Table'[Grade],'Table'[City]))
VAR _denom = CALCULATE(DISTINCTCOUNT('Table'[Student ID]),ALLEXCEPT('Table','Table'[Grade]))
RETURN DIVIDE(_num,_denom)
@afaherty can you please create new thread and post the representative pbix please?
@afaherty try this
Measure = CALCULATE(DISTINCTCOUNT('Table'[Student ID]),ALLEXCEPT('Table','Table'[Grade],'Table'[City]))
@smpa01 Hi! Thank you, you always come to my rescue! I had already gotten the totals, but now I need to figure out the percentages which is where I'm stuck! 😓
@afaherty please provide the desired output for the given data
<Redacted>
@afaherty please walk me through how are you getting the following?
Apologies, had a small miscalc.
Here is what it would be for the Juniors:
Sophomores:
Seniors:
Measure =
VAR _num = CALCULATE(DISTINCTCOUNT('Table'[Student ID]),ALLEXCEPT('Table','Table'[Grade],'Table'[City]))
VAR _denom = CALCULATE(DISTINCTCOUNT('Table'[Student ID]),ALLEXCEPT('Table','Table'[Grade]))
RETURN DIVIDE(_num,_denom)
Thank you @smpa01! Worked like a charm. I'm having a separate issue though where my slicer (which is "City") isn't working for the new matrix created with your measure. It's showing me all of the cities instead of whichever one I choose. All of the other visuals on the report canvas are complying with the slicer. Any ideas?
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.