Forum Discussion

abhishekc1's avatar
abhishekc1
Frequent Visitor
7 years ago
Solved

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 1 cl 1 1/1/2019 ...
  • v-frfei-msft's avatar
    7 years ago

    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" )
    

     

    pbix as attached.