Forum Discussion
VBAmazing
1 year agoFrequent Visitor
Count Distinct Customer IDs for New Customers using Measures Only
Hi All, This is my first post in this forum; I have done research ahead of time and found no questions that match my current use case exactly. I am working within a star schema and need to: ...
- Anonymous1 year ago
Hi, VBAmazing
Based on your information, I create sample tables:
Create a new table named Date:
Date = CALENDAR(MIN('Sale'[DeliveryDate]),MAX('Sale'[DeliveryDate]))Then create new measures:
FirstOrderDate = CALCULATE( MIN('Sale'[DeliveryDate]), ALLEXCEPT('Sale', 'Sale'[CustomerID], 'Sale'[SupplierID]) )IsFirstOrderDateInContext = VAR minContextDate = MIN('Date'[Date]) VAR maxContextDate = MAX('Date'[Date]) RETURN IF( [FirstOrderDate] >= minContextDate && [FirstOrderDate] <= maxContextDate, 1, 0 )DistinctNewCustomers = CALCULATE( DISTINCTCOUNT('Customer'[CustomerID]), FILTER( 'Customer', [IsFirstOrderDateInContext] = 1 ) )Put these measures in table visual, here is my preview:
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
VBAmazing
1 year agoFrequent Visitor
This does exactly what I need. Thank you for your reply!
Conceptually it makes a lot of sense and clarified some concepts for me. Super valuable response.