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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
CNH_1978
Contributor II
Contributor II

Find the difference between values in weeks (script)

Hi,

I have some data that i am loading in,

Name

Dim1

dim2

Date

Value

i want to add a field in the script that will show me the difference in values for each name by date. 

e.g.

NameDim1Dim2Dim3Dim425/06/2026/06/2027/06/20
Value1   199,448           1990.000748749749
Value2   175,729           1760.000937938938
Value3   121,676           1220.000372373374

 

so the new field will contain the following (if 25/06/20 was the first date in the data)

Name25/06/2026/06/2027/06/20
Value174810
Value293710
Value337211

 

I know i would have to use the peek function but i'm a bit lost. 

Can anyone help please?

I have attached some files. 

Thanks 🙂

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hi 

this script should work for you 

Data_TMP:
CrossTable(Date, Data, 5)
LOAD *
FROM
[C:\Users\Liron\Downloads\Test_Data.xlsx]
(ooxml, embedded labels, table is Data)
where RowNo()<=29;





Data:
Load 
	Name,
	Dim1,
	Dim2,
	Dim3,
	Dim4,
	Date,
	Data,
	if(Previous(Name)=Name,Data-previous(Data),Data) as DateDiff
Resident Data_TMP
order by Name , Date;

drop table Data_TMP;

View solution in original post

2 Replies
lironbaram
Partner - Master III
Partner - Master III

hi 

this script should work for you 

Data_TMP:
CrossTable(Date, Data, 5)
LOAD *
FROM
[C:\Users\Liron\Downloads\Test_Data.xlsx]
(ooxml, embedded labels, table is Data)
where RowNo()<=29;





Data:
Load 
	Name,
	Dim1,
	Dim2,
	Dim3,
	Dim4,
	Date,
	Data,
	if(Previous(Name)=Name,Data-previous(Data),Data) as DateDiff
Resident Data_TMP
order by Name , Date;

drop table Data_TMP;
CNH_1978
Contributor II
Contributor II
Author

fantastic, thanks very much 🙂