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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
1Francesco
Regular Visitor

A measure to count the users who had activity each day/week/month in the selected period

Hi community, 

Can you please advise me how I can count the number of users who have had activity each day, week or month in a selected period of time. 

I have a user login history table - UserLogins and a date table. 

UserLogins table:

LoginDwIdUserIdLoginDateWeekNumMonthNumWeekUserIdMonthUserId
201044U1232022-09-1620223820229U123202238U12320229
201489U1242022-09-1720223820229U124202238U12420229
201488U1252022-09-1820223920229U125202239U12520229
201487U1262022-09-1920223920229U126202239U12620229
201486U1272022-09-2020223920229U127202239U12720229
201485U1282022-09-2120223920229U128202239U12820229
201484U1292022-09-2220223920229U129202239U12920229
201483U1302022-09-2320223920229U130202239U13020229
201482U1312022-09-2420223920229U131202239U13120229


As you can see, I created a new WeekUserId and MonthUserId by combining the UserId and the Week or Month IDs. My idea was to compare the unique number of WeekUserId and the unique number of weeks for the selected time period to see if the user had a login in each week of the selected period. Something like 

Active Users - Monthly Login = IF(DISTINCTCOUNT(UserLogins[MonthUserId])=DISTINCTCOUNT('Date'[Month]),1,0), but unfortunately this does not work. 

Can you please advise me what is the best way to calculate it.

Thank you in advance and have a nice day!
1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @1Francesco ,

Test the below :

TEST = CALCULATE(DISTINCTCOUNT(Loguserid[UserId]),FILTER(ALL(Loguserid),Loguserid[MonthNum]=SELECTEDVALUE('date'[Month])))

The dax will get the  distinct activity user id according the month you selected:

vluwangmsft_0-1666235252420.pngvluwangmsft_1-1666235304651.png

 

Best Regards

Lucien

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @1Francesco ,

Test the below :

TEST = CALCULATE(DISTINCTCOUNT(Loguserid[UserId]),FILTER(ALL(Loguserid),Loguserid[MonthNum]=SELECTEDVALUE('date'[Month])))

The dax will get the  distinct activity user id according the month you selected:

vluwangmsft_0-1666235252420.pngvluwangmsft_1-1666235304651.png

 

Best Regards

Lucien

1Francesco
Regular Visitor

Hi singhsudha1301,

thanks a lot for your reply! Could you please describe in more detail how I could use this index to define if a selected user has been active every month in a selected time period?

Thank you! 
 

singhsudha1301
Frequent Visitor

Hi @1Francesco,

You can use RANKX DAX function to create a column and use the ID columns you have to create it. Something like below:

Index = RANKX (FILTER ( Table,
        EARLIER ( Table[WeekUser_id] ) = Table[WeekUser_id]
            && EARLIER ( Table[EventDateMonthYear] ) = Table[EventDateMonthYear]),
    Table[event_date], ,ASC)
In this, event_date is the date column, EnentDateMonthYear is a column derived from event_date for month and year data, because I wanted to check the activity count in a month.

Please refer the RANKX document for peroper understanding. 

Hope this helps!

Thank you

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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