Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gopikrishnach
Creator
Creator

adding 2 values and subtract from select row in Pivot table

Hi All,

i have one scenario, i want to create pivot table with 3 dimension and 1 expression. In expression i want to add the previous values by subtracting of current value.

For Example:

I have Company Name, Department,  Employee Name, Salary.

Iam creating Pivot table with Company Name, Department, Employee name as dimensions and sum(Salary) as Expression.

     

Company NameDepartment Employee NameSUM(Salary)Condition
ABCSales        AA10000                                    same
ABCProduction        BB15000                     Salary 'AA'-Salary 'BB'
ABCSupporting        CC20000              (salary 'AA'+Salary 'BB')-Salary 'CC'
ABCMarketing        DD30000           (salary 'AA'+Salary 'BB'+Salary 'CC')-Salary 'DD'
DEFSales         EE10000                                      same
DEFProduction         FF15000                    Salary 'EE'-Salary 'FF'
DEFSupporting        GG20000            (salary 'EE'+Salary 'FF')-Salary 'GG'
DEFMarketing         HH30000            (salary 'EE'+Salary 'FF'+Salary 'GG')-Salary 'HH'
1 Solution

Accepted Solutions
sunny_talwar

May be this:

=If(Aggr(RowNo(), [Company Name], [Employee Name]) = 1, Sum(Salary), Aggr(RangeSum(Above(Sum(Salary), 1, RowNo())), [Company Name], [Employee Name])-Sum(Salary))

Capture.PNG

View solution in original post

9 Replies
sunny_talwar

May be this:

=If(Aggr(RowNo(), [Company Name], [Employee Name]) = 1, Sum(Salary), Aggr(RangeSum(Above(Sum(Salary), 1, RowNo())), [Company Name], [Employee Name])-Sum(Salary))

Capture.PNG

gopikrishnach
Creator
Creator
Author

Hi Sunny T,

Can you please provide any thing i need to modify in editor and also please provide the script.

gopikrishnach
Creator
Creator
Author

Dear Sunny T,

Can you please provide the qvw file.

Regards,

Gopikrishna.

sunny_talwar

PFA

gopikrishnach
Creator
Creator
Author

Hi Sunny,

I have one more question. Please refer below screenshot and provide the qvw.

sunny_talwar

Please refer below screenshot and provide the qvw.

I just added the qvw my friend? What other qvw are you looking for?

gopikrishnach
Creator
Creator
Author

I Have another scenario that i want the final result as for dpr 2, (sum(dpr1) day value -dpr2 day value) in the attached screen shot.

sunny_talwar

I am sorry, I don't understand things just by looking at the images and a very brief description. Please read these and me or someone else might be able to help you better

QlikCommunity Tip: How to get answers to your post?

Preparing examples for Upload - Reduction and Data Scrambling

Uploading a Sample

Best,

Sunny

gopikrishnach
Creator
Creator
Author

I am uploading the data, please check once.

please refer the attached spread sheet. i want condition for result field in sheet1