Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
rkpatelqlikview
Creator III
Creator III

sum of highest sales contributed agent count in backend

Hi All,

Hope you are doing good.

I need some help on below requirement. Please support.

I have Agents and Sales.I need to show the agent count who contributed 70% from total sales.

Example: In below data My total sales for Jan-2020 month 140M from this 70% means 98M.

Here i want to see count of agents who contributed to 98M. First highest sales 50M,second 40M and third 30M.

It is reaching to more than 98M then my agent count is 3.

How to achieve this? Thanks in advance.

rkpatelqlikview_0-1595582784956.png

 

 

Labels (1)
  • SaaS

1 Solution

Accepted Solutions
Kushal_Chawda

Assuming that You have data like below

 

T1:
Load date#(MonthYear,'MMM-YY') as MonthYear,Sales,Agent;
Load * Inline [
MonthYear,Agent,Sales
Jan-20,A1,30
Jan-20,A2,20
Jan-20,A3,50
Jan-20,A4,40
Feb-20,A1,40
Feb-20,A2,100
Feb-20,A3,10
Feb-20,A4,20];

Left Join(T1)
Load MonthYear,
     sum(Sales) as MonthlySales
Resident T1
Group by MonthYear;

T2:
Load *,
    if(MonthYear<>Peek(MonthYear),1,if(peek([%Accum])>=0.7,0,1)) as [Agent_Flag_>70%];
Load MonthYear,
     Sales,
     if(MonthYear<>Peek(MonthYear),Sales/MonthlySales,
     RangeSum(Sales/MonthlySales,peek([%Accum]))) as [%Accum],
     Agent
Resident T1
Order by MonthYear,Sales desc;

Drop Table T1;

 

 

You can now show count of the Agent using set analysis as below

 

Count({<[Agent_Flag_>70%]={1}>}Agent)

 

View solution in original post

6 Replies
Taoufiq_Zarra

in Script ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
rkpatelqlikview
Creator III
Creator III
Author

Yes script level.

Kushal_Chawda

Assuming that You have data like below

 

T1:
Load date#(MonthYear,'MMM-YY') as MonthYear,Sales,Agent;
Load * Inline [
MonthYear,Agent,Sales
Jan-20,A1,30
Jan-20,A2,20
Jan-20,A3,50
Jan-20,A4,40
Feb-20,A1,40
Feb-20,A2,100
Feb-20,A3,10
Feb-20,A4,20];

Left Join(T1)
Load MonthYear,
     sum(Sales) as MonthlySales
Resident T1
Group by MonthYear;

T2:
Load *,
    if(MonthYear<>Peek(MonthYear),1,if(peek([%Accum])>=0.7,0,1)) as [Agent_Flag_>70%];
Load MonthYear,
     Sales,
     if(MonthYear<>Peek(MonthYear),Sales/MonthlySales,
     RangeSum(Sales/MonthlySales,peek([%Accum]))) as [%Accum],
     Agent
Resident T1
Order by MonthYear,Sales desc;

Drop Table T1;

 

 

You can now show count of the Agent using set analysis as below

 

Count({<[Agent_Flag_>70%]={1}>}Agent)

 

rkpatelqlikview
Creator III
Creator III
Author

Thanks Kush, Am just trying same way. I will check and update. Thanks again. 

rkpatelqlikview
Creator III
Creator III
Author

Thanks a lot Kush. Its giving accurate result.

Kushal_Chawda

Glad that it worked