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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
clarissa
Helper I
Helper I

Count orders of customer and create segment

Hi

 

I have customer-email adresses and order numbers as different columns. I'd like to calculate the number of orders per customer-email and then create a separate column "segment" based on the number of orders. 

The table should be able to show segments with then the connected net sales (same table).

 

How to achieve this?

7 REPLIES 7
harshnathani
Community Champion
Community Champion

Hi @clarissa ,

 

Please share sample data and the expected output te help you on this.

 

 

Regards,

HN

ok

 

I have the following data:

 

email cst.       order_no               

......                  abc

......                  efg

........                hijk

 

 

- I need to count the distinct order-No per e-mail cst

- I need an addition column to create segments based on number of orders, such as:

 

 

Segment = IF(
DISTINCTCOUNT(sales[order_no]) = 1,
"new",
IF(
DISTINCTCOUNT(sales[order_no]) = 2,
"repeat",
"loyal")
)
 
 

- I need to be able to show the values by segment

 

Does that help?

Hi @clarissa ,

 

 

1.jpg

 

 

 

Create a measure

 

DC = CALCULATE(DISTINCTCOUNT('Table'[Order No]),ALLEXCEPT('Table','Table'[email]))
 
 
Then create a New Table
Seg =

ADDCOLUMNS(
SUMMARIZE(
'Table',
'Table'[email],
"Distinct_", [DC]),
"Segment",
SWITCH(
TRUE(),
[Distinct_] = 1, "New",
[Distinct_] = 2, "Repeat",
"Loyal"
))
 
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

Hi @clarissa ,

 

Do Emails repaeat in you tble ?

 

Can you share some 10 like of sample?

 

Regards,

HN

Unfortunately I can't share the table, but the email is also not unique... so an e-mail address can come up a few times with different order numbers... can you work with this?  Thank you so much 

harshnathani
Community Champion
Community Champion

Hi @clarissa ,

 

You can try something like this

 

https://radacad.com/customers-grouped-by-count-of-their-orders-static-segmentation-in-power-bi

 

 

Do share sample data incase this does not work.

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Thank you.

 

Do you have a solution with a formula for measures? like summarize and group by?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.