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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Daya_Acc
Contributor II
Contributor II

Set Analysis to get the previous value of a field

Hi All,

I'm trying to get the previous value of a Channel field where channel start with Survey.

Base Data:

Sequence Number Channel
1 Website
2 Survey-1
3 Email
4 Event
5 Survey-2

 

Required Output Data:

Sequence Number Channel Output Data
1 Website -
2 Survey-1 Website
3 Email -
4 Event -
5 Survey-2 Event

 

Thanks in advance!

/Daya

Labels (2)
3 Replies
Clement15
Partner - Specialist
Partner - Specialist

Hello,
this should meet your need

 

TEST:
Load
*
Inline [
Sequence Number, Channel
1, Website
2, Survey-1
3, Email
4, Event
5, Survey-2
];

NoConcatenate

TEST2:
Load
*
,
if(WildMatch(Channel,'*Survey*')<>0,previous(Channel),null()) as [Output Data]
Resident TEST
order by [Sequence Number];

drop table TEST;

 

pallavi_96
Partner - Creator
Partner - Creator

Hi @Daya_Acc,

You can use below expression to get your desired outpu

If(Left(Channel, 6) = 'Survey', Peek('Channel', -1) , Null()) as PreviousSurveyChannel

 

AnusuyaRajavel
Partner - Contributor
Partner - Contributor

Try this:
load SequenceNumber,
Channel,
if(WildMatch(Channel,'*Survey*'),Previous(Channel),null()) as OutputData
resident table;