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.
Hi,
I am currently having a date table I use as slicer and I have:
1st Table
Table with all the visitors (one record for every day they visit it, therefore I have this DAX measure to calculate the Active Users:
Active Users (NEW) = CALCULATE(
DISTINCTCOUNT(Analytics_Visitors[Email]),
ALLSELECTED('calendar'[Month])
)
Visit Date | Account ID | |
15/01/2022 | personab@gmail.com | AB12345 |
16/01/2022 | personab@gmail.com | AB12345 |
19/01/2022 | xyz@gmail.com | XZ9876 |
25/02/2022 | xyz@gmail.com | XZ9876 |
In this example the active user formula returns 2 for Jan and 1 for February (The active users are defined with at least 1 visit per month.
2nd Table
Table with the users being the paid license holders, each email has a start and end date for when they are a named paid user. And calculating the total like this:
Total Named License Holders =
VAR CurrentDate = MAX('calendar'[Date])
VAR PaidUsers =
CALCULATE(
COUNTROWS('Paid Users - Master Data'),
ALL('calendar'),
'calendar'[Date]<=CurrentDate,
ISBLANK('Paid Users - Master Data'[LicenseExpirationDate])
|| 'Paid Users - Master Data'[LicenseExpirationDate]>=CurrentDate
)
VAR Result =
IF(
YEAR(CurrentDate)<=YEAR(TODAY()),
PaidUsers
)
RETURN
Result
Data example:
Account ID | Paid License Start Date | Paid License End Date | |
AB12345 | personab@gmail.com | 1/1/2022 | 31/3/2022 |
XZ9876 | xyz@gmail.com | 12/1/2022 | 12/4/2022 |
QW567 | nzc@test.com | 1/1/2022 | 31/12/2022 |
Solved! Go to Solution.
You could do something like
Active Named Users =
VAR CurrentDate = MAX('calendar'[Date])
VAR PaidUsers =
CALCULATETABLE(
VALUES('Paid Users - Master Data'[email]),
ALL('calendar'),
'calendar'[Date]<=CurrentDate,
ISBLANK('Paid Users - Master Data'[LicenseExpirationDate])
|| 'Paid Users - Master Data'[LicenseExpirationDate]>=CurrentDate
)
return CALCULATE( [Active Users (NEW)], TREATAS( PaidUsers, Analytics_Visitors[Email]) )
Hi @Anonymous ,
Please try this code:
Make yourActive Named Users =
VAR active =
CALCULATETABLE (
VALUES ( Analytics_Visitors[Email] ),
ALLSELECTED ( 'calendar'[Month] )
)
VAR named =
CALCULATETABLE (
VALUES ( 'Paid Users - Master Data'[Email] ),
FILTER (
ALLSELECTED ( 'Paid Users - Master Data' ),
[Paid License Start Date] >= MAX ( 'calendar'[Month] )
&& [Paid License End Date] >= MIN ( 'calendar'[Month] )
)
)
VAR active_and_named =
INTERSECT ( active, named )
RETURN
COUNTROWS ( active_and_named )
If you need more help, please share more example data.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You could do something like
Active Named Users =
VAR CurrentDate = MAX('calendar'[Date])
VAR PaidUsers =
CALCULATETABLE(
VALUES('Paid Users - Master Data'[email]),
ALL('calendar'),
'calendar'[Date]<=CurrentDate,
ISBLANK('Paid Users - Master Data'[LicenseExpirationDate])
|| 'Paid Users - Master Data'[LicenseExpirationDate]>=CurrentDate
)
return CALCULATE( [Active Users (NEW)], TREATAS( PaidUsers, Analytics_Visitors[Email]) )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
46 | |
22 | |
20 | |
15 | |
13 |
User | Count |
---|---|
49 | |
41 | |
39 | |
19 | |
19 |