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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.