Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

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
Highlighted
Partner
Partner

Re: Create new field which calculates sum of week vs previous week

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;
Highlighted
Partner
Partner

Re: Create new field which calculates sum of week vs previous week

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.

Highlighted
Partner
Partner

Re: Create new field which calculates sum of week vs previous week

hi 

it's strange , it is working for me perfectly

can you share your app , you used 

or your load script  

Highlighted
Partner
Partner

Re: Create new field which calculates sum of week vs previous week

@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.