Forum Discussion
Issue with DAX Function Not Displaying Totals on First Row Level in Matrix Table
- 8 months ago
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