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

Creating a variable to count customers spending over a certain amount

Last week I asked a question where I wanted to count customers spending more than £500 who were buying specific products. Someone gave me the answer to that particular question with this bit of code: count({<location_id={"=Sum(customer_gross_sales)>500"}>}location_id)

I then want to be able to say what percentage of customers spending more than £500 are buying each product. My question is how to count all of the customers and not just those related to the particular product? Could I establish a variable to count them and then use this?

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

count({<location_id={"=Sum(customer_gross_sales)>500"}>}location_id) / count({1}location_id)

View solution in original post

9 Replies
anbu1984
Master III
Master III

count({<location_id={"=Sum(customer_gross_sales)>500"}>}location_id) / count({1}location_id)

Not applicable
Author

Hi Peter,

It seems you would like to count how many customers who has having sales more than 500 for each Location, You can achieve using this Sum(Aggr(IF(count({<location_id={"=Sum(customer_gross_sales)>500"}>}location_id))>1,1),[location_id]))';

Regards,

Chinni Kanna

Anonymous
Not applicable
Author

Each customer has a distinct location_ID so customer and location_ID are synonymous.

Anonymous
Not applicable
Author

Hi Anbu,

thanks for your reply. What does {1} do when put in front of location_ID?

Thanks,

Peter

anbu1984
Master III
Master III

In set analysis, 1 Represents the full set of all the records in the application

Count({1} location_ID) gives the count of all customers in your application

Anonymous
Not applicable
Author

Thanks. I'm pretty sure that's the answer then. Thanks for your help.

Not applicable
Author

try this then

Sum(Aggr(IF(Sum(customer_gross_sales)>500,1),[Cust ID]))


Regards,

Chinni Kanna

Anonymous
Not applicable
Author

That didn't actually seem to work as it gave a different number for each product when the number of customers spending more than £500 is the same for each product (although they don't buy all products).

Not applicable
Author

Hi Peter,

Please send us sample data

Thanks & Regards,

Chinni Kanna