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
Praj
Helper I
Helper I

DAX measure to calculate users who are active at the selected timeframe

Hey Everyone,

 

I am trying to calculate the % of users who had an event and had an active membership during the selected timeframe. For example, I have below two tables.

 

1) Membership Info - Table about when a member joined the membership

Praj_0-1709030650809.png 

2) Event Info - Table when a member had an event

Praj_1-1709030691451.png

 

I want to calulate the % of member who had an event and were active at the selected timeframe using the below slicer. Say, If my user selects April and May in the slicer, the output should be 100% because at the end of May, 3 users had event and their membership start date was before May. Similarly, If my user select July, the output should be 25% as only 1 user had en event in July and by the end of July we had 4 users whose membership start date was <= 31st of July 

Praj_3-1709030893376.png

 

I am able to get the distinct user who had an event (i,e I am able to get the right number for numerator) however, facing error with denominator. I did write the below code but with incorrect result

Measure = 
var selected_date = SELECTEDVALUE(Sheet2[Event Date])
var memberswithmemship =
    CALCULATETABLE(
        VALUES(Sheet1[User ID]),
        Sheet1[Membership Date] <= selected_date
    )
return COUNTROWS(memberswithmemship)

 

If anyone had similar usecase or anyone know a possible solution/approach I would be really grateful if you share the same. 

 

Thanks in advance

 

Praj

 

3 REPLIES 3
Praj
Helper I
Helper I

Hi @lbendlin , 

 

Thanks for your response. Below is the sample data as provided in the screenshot.  I am trying to calulate the % of members who had an event and were part of membership at the selected timeframe.Say, If my user selects April and May in the slicer, the output should be 100% because at the end of May, 3 users had event and their membership start date was before May. Similarly, If my user select July, the output should be 25% as only 1 user had en event in July and by the end of July we had 4 users whose membership start date was <= 31st of July 

 

Membership Info Table 

User IDMembership Date
101-Jan-22
201-Jan-22
301-Apr-22
401-Jun-22
701-Aug-22
501-Sep-22
601-Sep-22
801-Oct-22
901-Nov-22
1001-Dec-22

 

Event Info

User IDEvent Date
101-Apr-22
201-Apr-22
305-Apr-22
101-May-22
401-Jul-22
501-Oct-22
505-Oct-22
805-Oct-22
909-Dec-22
1009-Dec-22

your sample data is not covering your scenarios well.

 

lbendlin_0-1709164104891.png

 

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.