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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply

How to count active and inactive users based on login status?

Hi guys,

 

I have the below database table based on the login status of Users on our system.

login staging.PNG

2 - Inactive 

1 - Active

 

I'm trying to count the users who logged-in (and didn't logged-in) for specific days. For simpler illustration purposes, let's take June 12 and July 12 2018 as an example (queried in database above).

 

As you can see, I selected in my filter Months June and July with the 3 users. Ideally it shouldn't count more than 3 in all of the bar chart since we only have 3 users. 

 

Basically the general rules are

1. If user is “Active” even for ONE day then we should include that user only in the “ACTIVE” user count. 
2. If the user is not all “Active” for the entire period then ONLY we should show that user in the “Inactive user” group.

 

Meaning to say, for the 12th day, it should only count 1 INACTIVE USER and not 3. My "Value" in chart is "Count of UserID".

I manage to succesfully count it in the measure in the "inactive users" and "active users" below but wasn't successful in implementing this as well in the chart.

 

Can you please help me on this one? Thanks!

chart.PNG

 

 

 

 

3 REPLIES 3
v-qiuyu-msft
Community Support
Community Support

Hi @junyetzotomayor,

 

You can create measures below: 

 

Active = CALCULATE(DISTINCTCOUNT(Table1[UserID]),FILTER(ALLSELECTED('Table1'),'Table1'[Login Status]=1&&Table1[Day]=MAX('Table1'[Day])))

 

Inactive = CALCULATE(DISTINCTCOUNT(Table1[UserID]),FILTER(ALLSELECTED(Table1),Table1[Day]=MAX('Table1'[Day])))-CALCULATE(DISTINCTCOUNT(Table1[UserID]),FILTER(ALLSELECTED('Table1'),'Table1'[Login Status]=1&& 'Table1'[Day]=MAX('Table1'[Day])))

 

 

q1.PNG

 

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-qiuyu-msft,

 

Thanks for the feedback. Just a few more queries below.

 

1. I added 'Active' and 'Inactive' cards and filters in the PBI. Why is it counting only 1 inactive user wherein all users have at least logged in recordin my specifed timeframe (all dates selected).

2. Why the counts in the cards are showing different from the chart.

 

Capture.PNG

 

 

 

 

Hi @junyetzotomayor,

 

This is due to the chart has placed Day column in chart X axis, which will filter measures. While you place my measures in card visual, it process whole table and display values based on final day, in your scenario, it's 13. This is expected. 

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.