Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
charlie2
Contributor III
Contributor III

Accumulative Sales Hierarchy Belong To in Script

Hi everyone,

I have a table with the sales per Sales Rep and my challenge is to calculate the sales generated by each sales team, therefore aggregating the sales per team. 

I have a table like that with the sales per Sales Rep (RSM):

RSMYearSales
12021 5.000
22021 4.000
32021 3.200
42021 2.560
52021 2.048
62021 10.240
72021 51.200
82021 256.000
92021 204.800
102021 163.840
12020 131.072
22020 2.048
32020 10.240
42020 51.200
52020 256.000
62020 204.800
72020 163.840
82020 131.072
92020 204.850
102020 163.890

 

Then, I have a separate table with the head of each Sales Rep (VORG1), which form a sales team. In some cases, the VORG1 has another sales head, indicated in VORG2. The table looks like that:

RSMVORG1VORG2
111
211
311
441
541
641
741
899
999
1099

 

My goal is to have a table with the sales per Sales Rep (RSM) and another column with the accumulated sales per team. Like that:

RSMYearSalesVORG1VORG2Sales_VORG1Sales_VORG2
12021 5.000119.760329.248
22021 4.000119.760329.248
32021 3.200119.760329.248
42021 2.56041319.488329.248
52021 2.04841319.488329.248
62021 10.24041319.488329.248
72021 51.20041319.488329.248
82021 256.00099499.712499.712
92021 204.80099499.712499.712
102021 163.84099499.712499.712
12020 131.0721163.488819.200
22020 2.0481163.488819.200
32020 10.2401163.488819.200
42020 51.20041755.712819.200
52020 256.00041755.712819.200
62020 204.80041755.712819.200
72020 163.84041755.712819.200
82020 131.07299368.740368.740
92020 204.85099368.740368.740
102020 163.89099368.740368.740

 

There's a similar question posted here: https://community.qlik.com/t5/App-Development/Accumulative-hierarchy-calculation-in-script/td-p/1659...

Unfortunately, I didn't manage to get the desired output. The main difference is that I need the sales of the parents and not the children.

Any help is highly appreciated!

0 Replies