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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.