Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
pal25
Contributor III
Contributor III

How to get the weekday name for the latest date. ?

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 

1 Solution

Accepted Solutions
sidhiq91
Specialist II
Specialist II

@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.

View solution in original post

6 Replies
sidhiq91
Specialist II
Specialist II

@pal25  Could you please provide some sample data and expected output which will help us to get better understanding and can help you.

pal25
Contributor III
Contributor III
Author

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_0-1656688551025.png

 

sidhiq91
Specialist II
Specialist II

@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.

charishma01
Contributor
Contributor

hi
Formula for weekday name
Weekday(Field name) as new name
pal25
Contributor III
Contributor III
Author

Thanks @charishma01  and @sidhiq91 

Works for me 🙂

sidhiq91
Specialist II
Specialist II

@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.