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
abhishekc1
Frequent Visitor

Total orders by category

Hi All, Need your help with the following: My data looks like this- I have a data table that has the following fields:

 

Order IDCustomer idDateAmountProduct NameLocation

 OD 1cl 11/1/2019100p1L1
OD 2cl 21/1/2019290p2L2
 OD 3cl 31/1/2019201P2L1
 OD 4cl 41/2/2019170P5L3
 OD 5cl 51/2/2019222P2L1
 OD 6cl 61/2/2019345p1L1
 OD 7cl 31/2/2019213p1L2
 OD 8cl 41/2/2019332P3L2
 OD 9cl 51/3/2019112P3L3
 OD 10cl 61/3/2019145P4L3
 OD 11cl 11/3/2019112P4L3

 

It has an active relationship with a productkey table

 

ProductCategory
p1cat 1
p2cat2 
p3cat 1
p4cat 3
p5cat 2
p6cat 1

 

My requirement is to split the ordering customers into 2 buckets. Bucket 1) Customers who ordered 1-3 (total orders) times in a month 2) Customers with 4 (total orders) and more orders in a month Post this, i need to find out how many customers in each bucket order from the categories mentioned above in the product table. Any help will be deeply appreciated. Thanks in advance

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @abhishekc1 ,

 

One sample for your reference, please check the following steps as below.

 

1. Create a calculated column in order table.

 

Yearmonth = YEAR('Order'[Date]) *100 + MONTH('Order'[Date])

2. To create another calculated column to get the excepted result.

result = 
VAR coun =
    CALCULATE (
        COUNT ( 'Order'[Customer id] ),
        FILTER (
            'Order',
            'Order'[Customer id] = EARLIER ( 'Order'[Customer id] )
                && 'Order'[Yearmonth] = EARLIER ( 'Order'[Yearmonth] )
        )
    )
RETURN
    IF ( coun < 4, "ordered 1-3 ", "ordered more that 4" )

Capture.PNG

 

pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @abhishekc1 ,

 

One sample for your reference, please check the following steps as below.

 

1. Create a calculated column in order table.

 

Yearmonth = YEAR('Order'[Date]) *100 + MONTH('Order'[Date])

2. To create another calculated column to get the excepted result.

result = 
VAR coun =
    CALCULATE (
        COUNT ( 'Order'[Customer id] ),
        FILTER (
            'Order',
            'Order'[Customer id] = EARLIER ( 'Order'[Customer id] )
                && 'Order'[Yearmonth] = EARLIER ( 'Order'[Yearmonth] )
        )
    )
RETURN
    IF ( coun < 4, "ordered 1-3 ", "ordered more that 4" )

Capture.PNG

 

pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

You’re a rockstar. Thank you so much and I’m terribly sorry I couldn’t reply earlier. Your solution worked like a charm.

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.