Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply

Issue with DAX Function Not Displaying Totals on First Row Level in Matrix Table

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"

kenyaherring93_0-1765304241567.png

 

1 ACCEPTED SOLUTION
Jaywant-Thorat
Resolver IV
Resolver IV

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

View solution in original post

3 REPLIES 3
Jaywant-Thorat
Resolver IV
Resolver IV

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.

kenyaherring93_0-1765321050233.png

 

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!

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.