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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
hermanitor
Contributor III
Contributor III

Changing Fields Based on Previous Values

Hi,

Am trying to change the field based on a condition to the previous entry....(I can do the first one, but not the second and thirds ones....!).
Table Below
EmpID, Date, Shift
3,01/10/22,A
3,02/10/22,/
3,03/10/22,B
3,04/10/22,/
3,05/10/22,/
3,06/10/22,/

I can using the previous/peek command change the first '/'.  But I can't use this when I have repeated /.
if (Shift = '/',Peek(Shift),Shift) as Shift2,
I have more than A's and B's in the list, but the '/' is my issue.  
Basically I want to change the '/' to the previous shift and then count based on the revised shift field.

Am I explaining myself?  If not, please contact.

 

Labels (2)
1 Solution

Accepted Solutions
QFabian
MVP
MVP

Hi @hermanitor , please try this, using peek function

Aux:
Load * INLINE [
EmpID, Date, Shift
3,01/10/22,A
3,02/10/22,/
3,03/10/22,B
3,04/10/22,/
3,05/10/22,/
3,06/10/22,/
];

Data:
Load
EmpID,
Date,
Shift,
if(Shift = '/', peek(Shift_New), Shift) as Shift_New
Resident Aux;
drop table Aux;

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.

View solution in original post

4 Replies
QFabian
MVP
MVP

Hi @hermanitor , please try this, using peek function

Aux:
Load * INLINE [
EmpID, Date, Shift
3,01/10/22,A
3,02/10/22,/
3,03/10/22,B
3,04/10/22,/
3,05/10/22,/
3,06/10/22,/
];

Data:
Load
EmpID,
Date,
Shift,
if(Shift = '/', peek(Shift_New), Shift) as Shift_New
Resident Aux;
drop table Aux;

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
hermanitor
Contributor III
Contributor III
Author

Hi Fabian,
Perfect.  Thanks for your support....AM curious why this works using shift2 twice in the syntax, but am guessing this is just how Qlik works!
I think I may have a solution to my issue!
So you are aware, I was looking at this to try and solve my issue, but I think I can now use this as my work around....

https://community.qlik.com/t5/App-Development/Qlik-Sense-Loop-With-Conditions/m-p/1987213#M81581

QFabian
MVP
MVP

Hi again, that's the main difference between peek and previous, peek can get the value from a recently calculated field in the same load statement.

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
hermanitor
Contributor III
Contributor III
Author

Again thanks for the advise, will be using peek a lot more going forward!