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
Anonymous
Not applicable

group customer by orders

Hi, 

My tasks if to calculate total customers into groups based on the total orders they made. 

For example: 

Total customers who made from 1 to 5 orders. 

Total customers who made from 6 to 10 orders. 

Total customers who made from 11+ orders. 

 

What is the formula to group these 3 customers segmentation like this? 

In this case, I use the sample_superstore. 

Hope you could help me! Thanks so much 

 

I made this customers segment in Tableau, but I dont know how to make it in Power Bi. This is the way I made in Tableau. 

1. Calculate Orders 1 - 5

order 1-5.png

2. Caculate number of Total Customers who made 1-5 orders. 

Number Customers 1-5.png

 

Thanks for reading! and hope to hear from you!! 

1 ACCEPTED SOLUTION

Hi again @Anonymous 

I updated my PBIX with the same dataset you have used in your Tableau workbook.

My existing measure is actually sufficient to do what you want.

 

I created the same visual you had in Tableau:

  1. Created First Purchase Date calculated column in Orders and related this to a First Purchase Date table:
    Date of First Purchase = 
    CALCULATE ( 
        MIN ( Orders[Order Date] ),
        ALLEXCEPT ( Orders, Orders[Customer ID] )
    )
    Note that I hid this column in Report View
  2. Created Monts Since First Purchase calculated columns:
    Months Since First Purchase = 
    VAR MonthIndex =
        DATEDIFF ( Orders[Date of First Purchase], Orders[Order Date], MONTH )
    RETURN
        "M" & FORMAT ( MonthIndex, "00" )
  3. Applied a Page Level Filter, Segment Name = "1 to 5"
  4. Placed my earlier measure Number of Customers by Order Count Segment in a matrix visual, with some conditional formatting similar to your Tableau example.

You could also create measures that apply particular segment filters, such as

Number Customer Purchase 1 to 5 =
CALCULATE ( 
    [Number of Customers by Order Count Segment],
    Segment[Segment Name] = "1 to 5"
)

PBIX attached. Please post back if needed.

 

Regards,

Owen

 

Note that when including both Months Since First Purchase and First Purchase Month on the visual , all customers have five or fewer orders.


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

30 REPLIES 30

Hi,

Check my reply dates July 6.  There is a download link there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Whom are you replying to?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur I forgot to tag you in the post!! Sorry!

Anonymous
Not applicable

Thank you for helping me to solve the problem!!

Really appricated!! 

OwenAuger
Super User
Super User

Hi @Anonymous 

In this situation, with Power BI you would typically use a Dynamic Segmentation pattern
(see here).

 

I have attached a sample PBIX using a version of the Superstore data.

 

The steps are:

  1. Load the Orders table
  2. Create a Segment table that looks like:image.png

     

  3. Create a measure Number of Customers by Order Count Segment
    following the pattern from the above link (more-or-less):
    Number of Customers by Order Count Segement = 
    IF (
        ISFILTERED ( Segment[Segment Name] ),
        COUNTROWS (
            FILTER (
                VALUES ( Orders[Customer ID] ),
                VAR OrderCount = CALCULATE ( DISTINCTCOUNT ( Orders[Order ID] ) )
                RETURN
                COUNTROWS (
                    FILTER (
                        Segment,
                        ( OrderCount >= Segment[Min Value] || ISBLANK ( Segment[Min Value] ) )
                        && ( OrderCount <= Segment[Max Value] || ISBLANK ( Segment[Max Value] ) )
                    )
                ) > 0
            )
        ),
        DISTINCTCOUNT ( Orders[Customer ID] )
    )
  4. Create a visual grouped by Segment Name with this measure:image.png

    This measure will naturally respond to any other filters applied.

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Your solution @OwenAuger  is excllent but have one small problem, when you clcik on the segment it doesn't give the number of orders for each segment , please look at the screen-shot below:

Segment of ordersSegment of orders

For Example if I click on 1 to 5 Segment the card  doesn't give the total no of order of this particuler segment (gives the total orders in all segments) , please advise.

@MAAbdullah_47  

If you place the same "segmented" measure on the card as is used on the other visual, you should see the segmented value there as well. 

Does that work in your case?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

@OwenAuger 

 

It gives only the number of Customers , Not No Of orders , got it? 

Hi @OwenAuger  
I couldn't , could you show me a screen-shot please ? 

Anonymous
Not applicable

Dear, 

Thank you for your solution. 

Could you please to spend time to make the customer segmentation into separated group? 

Like I did in Tableau, I calculated total number of different group of customer who made orders from 1-5, 6-10, 10+ 

number of customer with orders.PNG

In this case, you dont need to separate into B2B or C2C. just number of customer from each orders segmentation.

I would use this to build cohort analysis like this:

order segmentation result.PNG

 

Thanks for help!! 

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.