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

Count customer by product family

Hi,

I would like to get customer count by product family from a set of data with below criteria:

     Customer category = Cat-B

     Total Revenue by Customer >= $10000

Sample data:

Product FamilyCustomer CategoryCustomerRevenue
ACat-AAPPLE1300
ACat-BORANGE10000
BCat-BPEAR11000
CCat-AAPPLE140000
DCat-BPAPAYA30000
DCat-ACHERRY50000

The count result I expected for the above is as below:

Product FamilyCustomer Count
A1
B1
C0
D1

My current expression below only works correctly when i filter on just 1 Product Family. When I release the filter on Product Family, it returns incorrect count results. Please help.

COUNT(DISTINCT

  AGGR(

     IF (SUM ( {<$>*<CUSTOMER_CATEGORY ={"CAT-B"}>} REVENUE) >= 10000, CUSTOMER),

    CUSTOMER))

Thank you!

17 Replies
Not applicable
Author

Hi Sunny,

I have tried to create some mocked data in this attached app. I have included the expression for Revenue and also the Customer Count (which I need help on).

The Customer Count result that I would like to achieve is as per below table:

PRODUCT FAMILYCustomer Count
A3
B6
C2

If you filter on 1 Product Family at a time, you can get the correct answer, but when you remove filter to show all Product Family, the count is incorrect.

Thanks!

Alice

sunny_talwar

May be this

COUNT(DISTINCT AGGR(IF(SUM({$<FORECAST_CUST_CAT={"CAT B DISTRIBUTION","CAT B DIRECT"}, REV_CHANNEL ={"Y"}>} [DOLLARS]) >= 10000, END_CUSTOMER), [PRODUCT FAMILY], END_CUSTOMER))

Not applicable
Author

Hi Sunny,

It works fine in the mocked app (thanks very much!)

I tried to apply the same in my actual app with below but it does not work (return all "-").

Can you help me see what went wrong in the below expression?

COUNT(DISTINCT  AGGR( IF( SUM({<$>*< FORECAST_CUST_CAT={"CAT B DISTRIBUTION","CAT B DIRECT"}, OPS_REV_CHANNEL={"Y"}>}  [CR_DOLLARS])>=10000, END_CUSTOMER), [FAMILY], END_CUSTOMER))

Note:

OPS_REV_CHANNEL is the "REV_CHANNEL" in mocked data

CR_DOLLARS is the "DOLLARS" in mocked data

FAMILY is the "PRODUCT FAMILY" in mocked data

Thanks again,

Alice

sunny_talwar

Not sure, but may be this

Count(DISTINCT  Aggr(If(Sum({$<FORECAST_CUST_CAT = {"CAT B DISTRIBUTION","CAT B DIRECT"}, OPS_REV_CHANNEL = {"Y"}>}  [CR_DOLLARS]) >= 10000, END_CUSTOMER), [FAMILY], END_CUSTOMER))

Made changes to set analysis part

{<$>*< FORECAST_CUST_CAT -> {$<FORECAST_CUST_CAT

Not applicable
Author

Still the same, it doesn't work...

sunny_talwar

Don't really know

Not applicable
Author

It works now .

The reason it did not work earlier is due to I put too much comments in the expression window and some of them i did not realize that it was not being "commented".

Thanks so much Sunny!

Not applicable
Author

Hi Sunny,

Now I need to add one more condition/criteria for the customer count, i.e. data with invoice date within 1 year from today.

I amend the expression to below but it does not work. Please help. Thanks!

COUNT(

  AGGR(

    IF(

            SUM({<$>*<

            INVOICE_DATE > DATE(TODAY())-365,

            INVOICE_DATE <= DATE(TODAY())-0,

            FORECAST_CUST_CAT={"CAT B DISTRIBUTION","CAT B DIRECT"},

            OPS_REV_CHANNEL={"Y"}>}

  [CR_DOLLARS]) >=10000, END_CUSTOMER), FAMILY,

    END_CUSTOMER))

Note: the Invoice_Date is in xxxxx format.