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
awitt
Helper III
Helper III

Unique Value Count

Looking to create a measure or a column that identifies when a value reoccurs within a data set but isolates the multiple times it shows up in one unique occurance. 

 

Basically i am looking to return the column (again this could be in a measure) that identifies when a customer # is new. The issue with just doing a distinctcount is that it removes the times the customer reoccurs. By doing a simple count though, it is taking into consideration the # of items that customer bought which I dont want. For example, customer ABC is listed 6 times in this data set but a distinctcount would just give it a value of 1. I want the first time this customer orders, that customer to be considered new, but the second time (there is a date table related as well) that ABC customer to be tagged as a recurring customer. The result of this data would be 6 orders (1001 - 1006) featuring 4 new customer (ABC, XYZ, LMNO, & QRS) and 2 returning customers (ABC & XYZ). 

 

ItemOrder #Customer #Customer Type
Item 11001ABCNew
Item 21001ABC 
Item 31001ABC 
Item 41001ABC 
Item 11002XYZNew
Item 21002XYZ 
Item 31002XYZ 
Item 41002XYZ 
Item 51002XYZ 
Item 11003ABCReturning
Item 21003ABC 
Item 11004LMNONew
Item 21004LMNO 
Item 31004LMNO 
Item 11005XYZReturning
Item 21005XYZ 
Item 31005XYZ 
Item 11006QRSNew
Item 21006QRS 
Item 31006QRS 
Item 41006QRS 
Item 51006QRS 
Item 61006QRS 
1 ACCEPTED SOLUTION

I just reproduced your data set and, using this code, see this:

 

New/Recurring = 
VAR EarliestDate = 
    CALCULATE(
        MIN( Table2[date] ),
        ALLEXCEPT( Table2,Table2[Customer #] )
    )

RETURN 
    IF(
        SELECTEDVALUE( Table2[date] ) = EarliestDate,
        "New",
        "Returning"
    )

 

 

Example.jpgAre you using the date column in the table with the rest of the data or a date table? The way the measure works is to find the the unique earliest date for each Customer. Not sure how a date table would impact this.

View solution in original post

4 REPLIES 4
MitchM
Resolver II
Resolver II

Will this measure work?

New/Recurring = 
VAR EarliestDate = 
    CALCULATE(
        MIN( Table1[date] ),
        ALLEXCEPT( Table1,Table1[company] )
    )

RETURN 
    IF(
        SELECTEDVALUE( Table1[date] ) = EarliestDate,
        "New",
        "Returning"
    )

No - unfortunately that is showing everything as new. 

 

Capture.PNG

I just reproduced your data set and, using this code, see this:

 

New/Recurring = 
VAR EarliestDate = 
    CALCULATE(
        MIN( Table2[date] ),
        ALLEXCEPT( Table2,Table2[Customer #] )
    )

RETURN 
    IF(
        SELECTEDVALUE( Table2[date] ) = EarliestDate,
        "New",
        "Returning"
    )

 

 

Example.jpgAre you using the date column in the table with the rest of the data or a date table? The way the measure works is to find the the unique earliest date for each Customer. Not sure how a date table would impact this.

I think relating the date table is messing something up. When i use the data within this specifc data, your solution works. Thanks!

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.