Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
nickjose7
Creator
Creator

How to apply For Loop in this problem.

Hi,

I am trying to achieve the following and need urgent help to build the logic/code for the same in Qlikview:


Data:

Dealer IDSales Qty
1100
22000
3490
4500
53000
6870
74102
8810
9920
10100
115600
12140
13635
144700
15323
16100
171790
182300
19100
206000

Requirement:

TotalABC
X204610
Y345802040210880

3298


Logic:


X(Total): Total Count of Dealer IDs.

Y(Total): Total Sales Qty

XA: Count of Top dealers who have contributed in 50% of Y(Total) i.e. 17290. (Sales QTY has to be sorted in descending order)

YA: Sum of actual Sales Qty of the dealers found in XA because they have achieved 50% sale but their actual sale is not exactly 50%.

XB: Count of NEXT Top dealers(excluding the ones counted in XA) who have contributed in next 30% of Y(Total) i.e. 10374.

YB:Sum of actual Sales Qty of the dealers found in XB because they have achieved 30% sale but their actual sale is not exactly 30%.

XC: X(Total) - (XA + XB)

YC: Y(Total) - (YA + YB)

Somebody suggested 'For Loop' should be used but I need the correct code that gives the desired result. Any help would be highly appreciated.

Thanks

Nick


13 Replies
nickjose7
Creator
Creator
Author

Hi Kushal,

This is awesome. Thank you so much for your quickest help.

I have checked your solution it works very well.

Nick

nickjose7
Creator
Creator
Author

Hi Sergey,

Great solution. Works very well. Thank you so much for your kind help.

The only difficulty I now have is to decide whose solution I mark as correct because both are absolutely fine just with a difference of Script & expression level.

I am marking Kushal's answer as correct just on the basis of time otherwise both solutions are greatly appreciated.

Thanks a lot!!

Nick

Sergey_Shuklin
Specialist
Specialist

Glad to help 😃

Kushal_Chawda

That's great