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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
RE
Helper I
Helper I

Count number of users with ONLY a specific status

I have a table of users and the online course work that they have been assigned. Each user has multiple records because they are assigned several different courses and they can have a different status for each course. The three statuses are completed, in progress, and subscribed. I am trying to calculate the number of users that have never logged into a course (so users with a status of subscribed ONLY). Any measure/column I write counts users that have a status of subscribed, complete, and/or in progress. 

 

The latest calculated column I wrote looks like this: 

Never Logges In =
IF(TrainingTbl[Status] <> "Completed", TRUE(), FALSE()) &&
IF(TrainingTbl[Status] <> "In Progress", TRUE(), FALSE()) &&
IF(TrainingTbl[Status] = "Subscribed", TRUE(), FALSE())

1 ACCEPTED SOLUTION
bdymit
Resolver II
Resolver II

Users Only Subscribed =
COUNTROWS (
    FILTER (
        SUMMARIZE (
            TrainingTbl,
            TrainingTbl[Name],
            "Num Subscribed", CALCULATE ( COUNTA ( TrainingTbl[Status] ), TrainingTbl[Status] = "Subscribed" ),
            "Num Courses", CALCULATE ( COUNTA ( TrainingTbl[Status] ) )
        ),
        [Num Subscribed] = [Num Courses]
    )
)

 

See if this works. I am not sure how large your data set is, so it might be a little slow. 

 

It uses SUMMARIZE to create a virtual table that looks like this:

Name   Num Subscribed   Num Courses

Joe        3                             4

Nick      5                             5

Kate      1                             1

Sue       0                             4

 

It counts the number of courses assigned to the person, and then the number of courses with the Status "Subscribed"

 

Then it filters that table to people where the number of courses and number subscribed are the same.

 

Name   Num Subscribed   Num Courses

Nick      5                             5

Kate      1                             1

 

Then it counts the rows.

 

2

 

Let me know if that works in your data model.

 

Cheers!

 

Ben

View solution in original post

2 REPLIES 2
bdymit
Resolver II
Resolver II

Users Only Subscribed =
COUNTROWS (
    FILTER (
        SUMMARIZE (
            TrainingTbl,
            TrainingTbl[Name],
            "Num Subscribed", CALCULATE ( COUNTA ( TrainingTbl[Status] ), TrainingTbl[Status] = "Subscribed" ),
            "Num Courses", CALCULATE ( COUNTA ( TrainingTbl[Status] ) )
        ),
        [Num Subscribed] = [Num Courses]
    )
)

 

See if this works. I am not sure how large your data set is, so it might be a little slow. 

 

It uses SUMMARIZE to create a virtual table that looks like this:

Name   Num Subscribed   Num Courses

Joe        3                             4

Nick      5                             5

Kate      1                             1

Sue       0                             4

 

It counts the number of courses assigned to the person, and then the number of courses with the Status "Subscribed"

 

Then it filters that table to people where the number of courses and number subscribed are the same.

 

Name   Num Subscribed   Num Courses

Nick      5                             5

Kate      1                             1

 

Then it counts the rows.

 

2

 

Let me know if that works in your data model.

 

Cheers!

 

Ben

mattbrice
Solution Sage
Solution Sage

if you just need a number:

 

measure =
CALCULATE ( COUNTROWS ( TrainingTbl ), TrainingTbl[Status] = "Subscribed" )
 

So if a student is "Subscribed", it will count the student.  If the same student is "Subscribed" to 2 classes, this will count the student twice (and so on)

 

If you want a count of the unique students that are "Subscribed" to at least one course, you can do this:

 

measure =
CALCULATE (
    DISTINCTCOUNT ( TrainingTbl[StudentID] ), TrainingTbl[Status] = "Subscribed"
)

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.