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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
user5341567
Helper I
Helper I

Flagging customers as 'return' if they have more than one order

Hi all,

 

I have a table with one or more order_ids per customer_id, and I'm trying to flag customers who have more than one order_id as 'return' customers.

 

As an example below: I have customer_id and order_id, but I'm trying to populate customer_type.

 

order_ids 001, 002, 003, 004, and 005 have multiple records of the same customer_id, so I wish to flag that customer as 'Return'. order_id 006 only has one customer_id in the table, so I wish to flag that customer as 'New', etc.

 

user5341567_2-1741900994787.png

 

 

 

Has anyone tried to do this?

 

I tried to first count the number of orders per customer, then use another field to say 'if # of orders > 1 then return else new', but my formula returns 1. All of the solutions I have tried gives me 1.

 

Here's one of the formulas I tried:

 

# of orders =
CALCULATE (
    DISTINCTCOUNT ( Fact_orders[order_id] ),
    FILTER (
        ALL ( Fact_orders ),
        [customer_id] = MAX ( Fact_orders[customer_id] )
    )
)
 
Any insight would be greatly appreciated!
1 ACCEPTED SOLUTION
Deku
Super User
Super User

Deku_0-1741902829484.png

 

returning = 
var customerID = 'Table (3)'[customerID]
var orders =
CALCULATE(
    DISTINCTCOUNT( 'Table (3)'[orderId] )
    ,REMOVEFILTERS( 'Table (3)'[orderId] )
)
RETURN
IF( orders > 1, "Returning", "New" )

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

2 REPLIES 2
user5341567
Helper I
Helper I

This worked perfectly, thank you for your reply!

Deku
Super User
Super User

Deku_0-1741902829484.png

 

returning = 
var customerID = 'Table (3)'[customerID]
var orders =
CALCULATE(
    DISTINCTCOUNT( 'Table (3)'[orderId] )
    ,REMOVEFILTERS( 'Table (3)'[orderId] )
)
RETURN
IF( orders > 1, "Returning", "New" )

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.