Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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;
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;
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
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.
Again thanks for the advise, will be using peek a lot more going forward!