Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Logic to find the difference between values in a column

My input is like:

PDI IDSTAGESDATE
PDI1101/2/2016
PDI1203/2/2016
PDI1304/2/2016
PDI2101/3/2016
PDI2203/3/2016

Now,For each PDI i wanted to calculate the difference of each stages and store it in separate column.The output should be as follows:

Here age-10 is calculated by finding the difference between the dates of stage-10 and stage 20 and so on

PDI IDAGE-10AGE-20AGE-30DATE-10DATE-20DATE-30
PDI11201/2/20163/2/20164/2/2016
PDI22001/3/20163/3/2016-

can anyone help me with the logic and script for this scenario?

6 Replies
MarcoWedel

please explain how the difference between 1/2/2016 and 3/2/2016 is 1 while the difference between 3/2/2016 and 4/2/2016 is 2 ?

thanks

regards

Marco

Not applicable
Author

sorry that was wrong data

age-10 should be 2 and age-20 should be 1

Anonymous
Not applicable
Author

try this

In strtaight table

for Age-10 :

Count({<Stage ={'10'}>} Stage)

age-20

Count({<Stage ={'20'}>} Stage)

age-30

Count({<Stage ={'30'}>} Stage)

Date-10

=Only({<Stage ={'10'}>}Date)

Date-20

=Only({<Stage ={'20'}>}Date)

Date-30

=Only({<Stage ={'30'}>}Date)

   

PDIIDAge-10Age-20Age-30Date-10Date-20Date-30
221--4/2/2016
PDI111101/02/20163/2/20164/2/2016
PDI211001/03/20163/3/2016-
MarcoWedel

Hi,

maybe like this?

QlikCommunity_Thread_247061_Pic1.JPG

tabTemp:

LOAD * FROM [https://community.qlik.com/thread/247061] (html, codepage is 1252, embedded labels, table is @1);

table1:

Generic

LOAD [PDI ID],

    'DATE-'&STAGES,

    DATE

Resident tabTemp;

table1:

Generic

LOAD [PDI ID],

    'AGE-'&STAGES,

    Alt(If(Previous([PDI ID])=[PDI ID],Previous(DATE)-DATE),0)

Resident tabTemp

Order By [PDI ID], DATE desc;

DROP Table tabTemp;

hope this helps

regards

Marco

Not applicable
Author

Generic load concept was very useful thankyou

MarcoWedel

you're welcome

glad it worked for you

please close your thread if your question is answered:

Qlik Community Tip: Marking Replies as Correct or Helpful

thanks

regards

Marco