Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

CountIf CumulativeSum is < value.

I have three fields, Item, Customer and Percent Sales.

For each Item, I need to know how many Customers it takes to accumulate at least 80% sales.

For instance:

ItemCustomerPercentSalesCumulative Sales
1110%10%
1225%35%
1310%45%
1420%65%
1520%85%
165%90%
175%95%
185%100%
215%5%
225%10%
235%15%
245%20%
2520%40%
2620%60%
2725%85%
2810%95%
295%100%

Would give me the results:

ItemCount:CumulativeSales>=80
15
27

In Excel I could do a countif(CumulativeSales<=.8)+1 

How could I do this in Qlikview?

Please help with the cummulative sum and the count statement

Thank you!

1 Solution

Accepted Solutions
RedSky001
Partner - Creator III
Partner - Creator III

So I ended up doing this in the script as it was easier... (see attached file)

View solution in original post

12 Replies
RedSky001
Partner - Creator III
Partner - Creator III

Create a chart with item as the dimension and the following expresison.

count(DISTINCT if([Cumulative Sales] <= 0.8,Customer))

Not applicable
Author

I don't have a field for cumulative sum.  I only have Item, Customer and PercentSales.  Can you help me figure out how to get CumulativePercentSales first, then I can try the above.


Thanks!

RedSky001
Partner - Creator III
Partner - Creator III

create a chart with customer as the dimesion and the following expresison with RT as the label.

rangesum(sum(PercentSales), above(RT))

Not applicable
Author

Unfortunately, that's not working. 

If I do it only over customer, it's combining from multiple items.
If I do it over item and customer, the sums aren't making sence (should never go over 1)

I attached an example to my original post Please fix 

Thanks, Melanie

RedSky001
Partner - Creator III
Partner - Creator III

See the example. 

I am rushing this as I'm about to go home, but let me know how it looks.

Not applicable
Author

I need to add +1 to your count to make it work out right. (number <80 + 1 to count customer that makes it over 80)

I think this will work.  Thank you so much, I will play around.

Cheers!

Not applicable
Author

I left off one more parameter, which is still throwing things off.

I need it to do the cumulative percent based on an ordered list, PercentSales Desc

Any idea how to modify?

So close!

RedSky001
Partner - Creator III
Partner - Creator III

Are you saying the data sould be sorted like this:

Item Customer PercentSales
1 6 50.00%
1 7 50.00%
1 8 50.00%
2 1 50.00%
2 2 50.00%
2 3 50.00%
2 4 50.00%
2 9 50.00%
1 2 25.00%
2 7 25.00%
1 4 20.00%
1 5 20.00%
2 5 20.00%
2 6 20.00%
1 1 10.00%
1 3 10.00%
2 8 10.00%

I'm not sure I follow you, can you let me know what result you are expecting with the data you have provided?

Not applicable
Author

The original file had an error in it, some of the values that said 50 were supposed to be 5.  I had fixed the inline text, but forgot to reload before uploading.

The file now has the correct values, ones that match my original statement above.  The results I'm looking for are as follows:

Sort first by Item, then by PercentSales Descending.  Then Take Cumulative of PercentSales for each Item.  Then if that value is <=80% count it

Item

CustomerPercentSalesCumulative<=80%?
1225%25%1
1420%45%1
1520%65%1
1110%75%1
1310%85%0
165%90%0
175%95%0
185%100%0
2725%25%1
2520%45%1
2620%65%1
2810%75%1
215%80%1
225%85%0
235%90%0
245%95%0
295%100%0

Thanks