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
Anonymous
Not applicable

Distinct count of unique values filtering by ID and Date

Good morning to everybody,

I will explain my situation. In my dataset, I have records of connections to an app. I want to know which users have been loyal and which have not. A loyal user is one who has entered in the app 5 different days during the last month.

I am currently trying to make a dichotomous column that tells me if the user is loyal or not.

I have a measure for it (which works fine) which is as follows:

 

Loyal users =

Var usersbydate = SUMMARIZE(Table, Table[userid], "occurrences", IF(CALCULATE(DISTINCTCOUNT(Table[Date]), DATESINPERIOD('Calendar'[Date], MAX('Calendar'[Date]), -30, DAY))>=5, 1.0))

Var SumLoyal = SUMX(usersbydate, [occurrences])

RETURN COALESCE(SumLoyal, 0)

 

The problem is that doing it in a column is impossible for me, since you must filter by the last 30 days and then make a distinct count of the days filtered by the user ID. I need a calculated column because I want to use it for filtering and drill through. The only thing I have achieved has been to obtain if they have entered 5 different days, but not to do so for the last 30 days.

 

Any idea how to do it?

 

Thanks in advance for your attention.

 

Greetings,

1 ACCEPTED SOLUTION
Anonymous
Not applicable

No, I needed to do a Drill Throught, so that's why I was trying to do it with DAX. The only solution that I found is make a Calculated Table with a SUMMARIZE() function and link it in the model. Then I can use RELATED() to find the loyal users. 

View solution in original post

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you want to show only loyal users of the last month in the visual?

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

No, I needed to do a Drill Throught, so that's why I was trying to do it with DAX. The only solution that I found is make a Calculated Table with a SUMMARIZE() function and link it in the model. Then I can use RELATED() to find the loyal users. 

amitchandak
Super User
Super User

@Anonymous , A column can be dynamic based on slicer value. So you have to use a measure. You can use the same measure a visual level filter on drill-down page

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.