Forum Discussion
ChumaAmako
5 years agoHelper I
Distinct Count Based on Filter Expressions
Dear Community, I have a model with an Accounts, Orders, Order Details, Product Details and Calendar table, with all relationships in place. Please download anonymous pbix file HERE. I have a...
- 5 years ago
ChumaAmako - I would try this way:
No of Active Users = VAR __MaxDate = MAXX(ALL('Order Table'),[Order Start Date]) VAR __MinDate = __MaxDate - 28 VAR __Table = FILTER(ALL('Order Table'),[Order Start Date]>=__MinDate) RETURN COUNTROWS(DISTINCT(SELECTCOLUMNS(__Table,"Email",[User Email]))) - 5 years ago
Hi ChumaAmako ,
Create 2 measures as below:
_Count active = CALCULATE(COUNT('Accounts Table'[Email Address]),FILTER(ALL('Accounts Table'),'Accounts Table'[Email Address]=MAX('Accounts Table'[Email Address])&&'Accounts Table'[Days Since Last Purchase]<=28))_No of Active Users = CALCULATE(DISTINCTCOUNT('Accounts Table'[Email Address]),FILTER('Accounts Table','Accounts Table'[_Count active]>=1) )And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
Greg_Deckler
5 years agoCommunity Champion
ChumaAmako - I would try this way:
No of Active Users =
VAR __MaxDate = MAXX(ALL('Order Table'),[Order Start Date])
VAR __MinDate = __MaxDate - 28
VAR __Table = FILTER(ALL('Order Table'),[Order Start Date]>=__MinDate)
RETURN
COUNTROWS(DISTINCT(SELECTCOLUMNS(__Table,"Email",[User Email])))