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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

DAX to find Count Distinct of Row Lesser Than Certain Number

So I have a table as follows:

 

CustomersDays Since PurchasedOther Columns
Anya123-
Bob223-
Caroline6000-
Dally5732-
Anya 4511 

 

I want to find the COUNT of CUSTOMERS who have purchased within the ast 2000 days (and in this table see, for example Anya has purchased reently as wel as several days earlier, we would like to keep only Anya's recent purchase and hence the  COUNT should return 2 (since Dally and Caroline  have purchased > 2000 days before).

 

Sample Data: Download Excel File 

 

Thanks!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Try a measure like

countx(filter(summarize(Table, Table[Customers], "_1", min(Table[Days Since Purchased])),[_1]>2000),[Customers])

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@amitchandak 

 

Please stop using SUMMARIZE for anything else but grouping and do not recommend it to others, especially those that are not very familiar with the quirks of DAX. This function is "broken" and there are much better alternatives. If you want to know why, please read this: https://www.sqlbi.com/articles/all-the-secrets-of-summarize/

 

Thanks.

amitchandak
Super User
Super User

@Anonymous , Try a measure like

countx(filter(summarize(Table, Table[Customers], "_1", min(Table[Days Since Purchased])),[_1]>2000),[Customers])

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.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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