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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
komminenianusha
Partner - Contributor III
Partner - Contributor III

Create new field which calculates sum of week vs previous week

HI Team,

I have a requirement to create a new field which calculates sum of week vs Prev week.See the below image for reference.

This field has to be create in script level only not in UI level.

komminenianusha_0-1593439042331.png

Can any one please help me to create 'Expected output' field.Requirement is urgent. 

Thanks in advance.

Regards,

Anusha

4 Replies
lironbaram
Partner - Master III
Partner - Master III

hi 

this will create the calculated column 

dataTemp:
LOAD
	[Date],
	[Sales]
 FROM [lib://AttachedFiles/Sample Data.xlsx]
(ooxml, embedded labels, table is Sheet1);

data:
load *,
     if(isnull(Previous([Sales])),[Sales], [Sales]+Previous([Sales])) as [Expected Output]
Resident dataTemp
Order by [Date];

drop Table dataTemp;
komminenianusha
Partner - Contributor III
Partner - Contributor III
Author

Thanks for your response @lironbaram  . Followed your steps but the numbers are getting doubled instead of adding to previous week the values are getting doubled.

lironbaram
Partner - Master III
Partner - Master III

hi 

it's strange , it is working for me perfectly

can you share your app , you used 

or your load script  

komminenianusha
Partner - Contributor III
Partner - Contributor III
Author

@lironbaram  I have more fields .In sample file i given only two fields but i have 7 fields in table  may be because of more fields i am getting double records.

Thanks in advance.