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!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hello! I am currently trying to display a matrix table of training courses under each training course you will see user name and the status of whether they have Completed or Not Completed a course.
Here is my DAX function and my pbx file is attached. When there is only ONE user under the training course the status icon still shows never to the Training Course name (the level above it). I don't know how to fix this.
Status Icon or Count =
VAR CompletedFlag = SELECTEDVALUE('Training Metrics'[ComCode], 0)
VAR NotCompletedFlag = SELECTEDVALUE('Training Metrics'[ComCode], 0)
VAR CountCompleted = CALCULATE(COUNTROWS('Training Metrics'), 'Training Metrics'[ComCode] = "1")+0
VAR CountNotCompleted = CALCULATE(COUNTROWS('Training Metrics'), 'Training Metrics'[ComCode] = "0")+0
VAR TotalUsers = COUNTROWS(ALL('Training Metrics'[User]))
RETURN
SWITCH(
TRUE(),
// Case when there is only one user in the current context
HASONEVALUE('Training Metrics'[User]),
SWITCH(
TRUE(),
CompletedFlag = "1", "✔", // Show check mark if completed
NotCompletedFlag = "0", "✖", // Show cross mark if not completed
BLANK() // Otherwise, show nothing
),
// Case when there are multiple users (subtotal or total)
IF(
CountCompleted = TotalUsers, // If all users have completed
"✔ All " & CountCompleted & " Users Completed", // Show check mark
CountCompleted & " Completed | " & CountNotCompleted & " Not Completed" // Otherwise, show counts
)
)
You can see here the counts show perfectly when there are multiple users. When there is only one user the status icon is displayed next to the course name. It should display "One user completed/incomplete"
Solved! Go to Solution.
Hi @kenyaherring93,
You're close — only two things are causing the unexpected behavior:
1) You're using HASONEVALUE('Training Metrics'[User]) (or SELECTEDVALUE) to decide when to show the per-user icon — that checks how many user values exist in the current filter context, so when a course has only one user it evaluates true and the measure treats the course row like a user row. Instead you want to check whether the matrix is currently showing the User level (i.e. the visual has User in scope). Use ISINSCOPE('Training Metrics'[User]) for that. ISINSCOPE tells you whether that column is the current row-level in the visual — which avoids the “one user under the course” problem.
2) Your TotalUsers currently counts all users in the model (or uses ALL(...)) so the “All users completed” test is wrong. You need the number of users in the current course context — use COUNTROWS( VALUES('Training Metrics'[User]) ) or DISTINCTCOUNT('Training Metrics'[User]) instead.
Fixed Measure:
Status Icon or Count =
VAR CompletedFlag = SELECTEDVALUE('Training Metrics'[ComCode])
VAR CountCompleted =
CALCULATE(
COUNTROWS('Training Metrics'),
'Training Metrics'[ComCode] = "1"
)
VAR CountNotCompleted =
CALCULATE(
COUNTROWS('Training Metrics'),
'Training Metrics'[ComCode] = "0"
)
VAR TotalUsers = COUNTROWS( VALUES( 'Training Metrics'[User] ) )
RETURN
IF(
-- If we are at the User row in the matrix, show icon for that user
ISINSCOPE( 'Training Metrics'[User] ),
SWITCH(
TRUE(),
CompletedFlag = "1", "✔",
CompletedFlag = "0", "✖",
BLANK()
),
-- Otherwise (course row / subtotal / total), show aggregated text/counts
IF(
TotalUsers = 0,
BLANK(),
IF(
CountCompleted = TotalUsers,
"✔ All " & TotalUsers & " Users Completed",
CountCompleted & " Completed | " & CountNotCompleted & " Not Completed"
)
)
)
=======================================================
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Jaywant Thorat | MCT | Data Analytics Coach
Linkedin: https://www.linkedin.com/in/jaywantthorat/
Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
#MissionPowerBIBharat
LIVE with Jaywant Thorat from 15 Dec 2025
8 Days | 8 Sessions | 1 hr daily | 100% Free
Hi @kenyaherring93,
You're close — only two things are causing the unexpected behavior:
1) You're using HASONEVALUE('Training Metrics'[User]) (or SELECTEDVALUE) to decide when to show the per-user icon — that checks how many user values exist in the current filter context, so when a course has only one user it evaluates true and the measure treats the course row like a user row. Instead you want to check whether the matrix is currently showing the User level (i.e. the visual has User in scope). Use ISINSCOPE('Training Metrics'[User]) for that. ISINSCOPE tells you whether that column is the current row-level in the visual — which avoids the “one user under the course” problem.
2) Your TotalUsers currently counts all users in the model (or uses ALL(...)) so the “All users completed” test is wrong. You need the number of users in the current course context — use COUNTROWS( VALUES('Training Metrics'[User]) ) or DISTINCTCOUNT('Training Metrics'[User]) instead.
Fixed Measure:
Status Icon or Count =
VAR CompletedFlag = SELECTEDVALUE('Training Metrics'[ComCode])
VAR CountCompleted =
CALCULATE(
COUNTROWS('Training Metrics'),
'Training Metrics'[ComCode] = "1"
)
VAR CountNotCompleted =
CALCULATE(
COUNTROWS('Training Metrics'),
'Training Metrics'[ComCode] = "0"
)
VAR TotalUsers = COUNTROWS( VALUES( 'Training Metrics'[User] ) )
RETURN
IF(
-- If we are at the User row in the matrix, show icon for that user
ISINSCOPE( 'Training Metrics'[User] ),
SWITCH(
TRUE(),
CompletedFlag = "1", "✔",
CompletedFlag = "0", "✖",
BLANK()
),
-- Otherwise (course row / subtotal / total), show aggregated text/counts
IF(
TotalUsers = 0,
BLANK(),
IF(
CountCompleted = TotalUsers,
"✔ All " & TotalUsers & " Users Completed",
CountCompleted & " Completed | " & CountNotCompleted & " Not Completed"
)
)
)
=======================================================
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Jaywant Thorat | MCT | Data Analytics Coach
Linkedin: https://www.linkedin.com/in/jaywantthorat/
Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
#MissionPowerBIBharat
LIVE with Jaywant Thorat from 15 Dec 2025
8 Days | 8 Sessions | 1 hr daily | 100% Free
Hey! I just ran into another issue. The issue is there are some cases where a employee will appear more than once. Two rows will show the same user and same course name but if one of those records show a date under Date Completed column it should remove the other record or rule out thats it's been completed.
So in my matrix table it doesn't show "Jane Doe" because there's two instances of the same course name Need help
THANK YOU SO MUCH. This works!
| User | Count |
|---|---|
| 51 | |
| 37 | |
| 31 | |
| 21 | |
| 19 |
| User | Count |
|---|---|
| 138 | |
| 102 | |
| 59 | |
| 36 | |
| 35 |