Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am new to Qlik. Can anyone help with the formula to get the weekday name for the latest date the data.
Also, i want to use this calculated latest weekday to compare with another existing weekday field in order to fetch a value. How can i use this in that expression / set analysis.
Any help would be appreciated
@pal25 Please follow the below code in the Script Editor first:
SET DayNames='Monday;Tuesday;Wednesday;Thursday;Friday;Saturday;Sunday';
NoConcatenate
Temp:
Load * Inline [
Date,Weekday,PrepandemicValue,PostpandemicValue
, Monday,14,
, Thursday,13,
, Tuesday,13,
, Wednesday,16,
, Friday,10,
, Saturday,18,
, Sunday,19,
27/06/2022,,,6
28/06/2022,,,4
29/06/2022,,,5
30/06/2022,,,7
01/07/2022,,,3
];
NoConcatenate
Temp1:
Load Date(Max(Date,'DD/MM/YYYY')) as Maxday,
Weekday(Max(Date)) as MaxWeekday
Resident Temp;
Let VMaxday=Peek('Maxday',0,'Temp1');
Let VMaxWeekday=Peek('MaxWeekday',0,'Temp1');
NoConcatenate
Temp2:
Load Date,
PostpandemicValue,
'Postpandemic' as Flag
Resident Temp
where Date='$(VMaxday)';
Concatenate
Load Weekday,
PrepandemicValue,
'Prepandemic' as Flag
Resident Temp
Where Weekday='$(VMaxWeekday)';
Drop table Temp, Temp1;
Exit Script;
In the Front End Sum(PostpandemicValue)/Sum(PrepandemicValue)
Expected output screenshot is attached.
If this resolved your issue, please like and accept it as solution.
@pal25 Could you please provide some sample data and expected output which will help us to get better understanding and can help you.
Hey @sidhiq91
My data looks like this (in the pic)
Requirement - To get Pre pandemic weekday avg of the same day as the weekday of the latest date (output is 10 ( for Friday which matches weekday of 1 july (latest date))) as per below data
@pal25 Please follow the below code in the Script Editor first:
SET DayNames='Monday;Tuesday;Wednesday;Thursday;Friday;Saturday;Sunday';
NoConcatenate
Temp:
Load * Inline [
Date,Weekday,PrepandemicValue,PostpandemicValue
, Monday,14,
, Thursday,13,
, Tuesday,13,
, Wednesday,16,
, Friday,10,
, Saturday,18,
, Sunday,19,
27/06/2022,,,6
28/06/2022,,,4
29/06/2022,,,5
30/06/2022,,,7
01/07/2022,,,3
];
NoConcatenate
Temp1:
Load Date(Max(Date,'DD/MM/YYYY')) as Maxday,
Weekday(Max(Date)) as MaxWeekday
Resident Temp;
Let VMaxday=Peek('Maxday',0,'Temp1');
Let VMaxWeekday=Peek('MaxWeekday',0,'Temp1');
NoConcatenate
Temp2:
Load Date,
PostpandemicValue,
'Postpandemic' as Flag
Resident Temp
where Date='$(VMaxday)';
Concatenate
Load Weekday,
PrepandemicValue,
'Prepandemic' as Flag
Resident Temp
Where Weekday='$(VMaxWeekday)';
Drop table Temp, Temp1;
Exit Script;
In the Front End Sum(PostpandemicValue)/Sum(PrepandemicValue)
Expected output screenshot is attached.
If this resolved your issue, please like and accept it as solution.
Thanks @charishma01 and @sidhiq91
Works for me 🙂
@pal25 Could you please like and accept it as a solution if it has resolved your issue so that it could benefit other users as well.