Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying to achieve the following and need urgent help to build the logic/code for the same in Qlikview:
Data:
| Dealer ID | Sales Qty |
| 1 | 100 |
| 2 | 2000 |
| 3 | 490 |
| 4 | 500 |
| 5 | 3000 |
| 6 | 870 |
| 7 | 4102 |
| 8 | 810 |
| 9 | 920 |
| 10 | 100 |
| 11 | 5600 |
| 12 | 140 |
| 13 | 635 |
| 14 | 4700 |
| 15 | 323 |
| 16 | 100 |
| 17 | 1790 |
| 18 | 2300 |
| 19 | 100 |
| 20 | 6000 |
Requirement:
| Total | A | B | C | |
| X | 20 | 4 | 6 | 10 |
| Y | 34580 | 20402 | 10880 | 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
Hi Kushal,
This is awesome. Thank you so much for your quickest help. ![]()
I have checked your solution it works very well.
Nick
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
Glad to help 😃
That's great ![]()