Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Vishal
Contributor II
Contributor II

Date group by is not working.

Hello Everyone, 

Please refer to below table, wherein I have 'SHIP_DATE' and 'QYT_DISPENSED', and the column Z i.e. 'week_date' I have created using the code as - date(if(WeekDay(SHIP_DATE,0)=4,SHIP_DATE, WeekEnd(SHIP_DATE,0,4)+1)) as week_date - which is basically giving Friday if the date is Friday, otherwise round off the date to the next Friday. 

Vishal_0-1659698259227.png

Now, I need to replicate the below SAS code into Qlikview - 

Vishal_0-1659701644090.png

I have used the below code - 

Vishal_2-1659699982251.png

However, the result is not as I wanted. It may seem trivial to some but I am really stuck here. Kindly help. The result I am getting is - 

Vishal_3-1659700232035.png

It is supposed to show 04-22-16 = 16 or 04-15-16 = 6. It is not grouping the dates as its supposed to. The problem I have figured is that it is grouping the 'QYT_DISPENSED' of actual Fridays separately than the dates I have converted to Friday. See below - 

Vishal_4-1659701224782.png

Please help! Thanks in advance.

Labels (3)
1 Solution

Accepted Solutions
BrunPierre
Master
Master

Maybe this;

[Temp_interim.nps_starter_pack];
NoConcatenate
LOAD DATE(DATE#(week_date,'DD-MM-YYYY'),'MM-DD-YYYY') as weekdate,
QTY_DISPENSED as NPS,
'SD_starter_pack_NPS' as Flag

resident interim.SD_final;
Where wildmatch(NDC_NBR,'000123456') and not wildmatch(ACCOUNT_NAME,'*BLOCKED*');

NoConcatenate
interim.nps_starter_pack:
LOAD weekdate,
Flag,
SUM(NPS) as NPS,

resident [Temp_interim.nps_starter_pack]
Group by weekdate,Flag;
Order by weekdate,Flag;
Drop table [Temp_interim.nps_starter_pack];

View solution in original post

2 Replies
BrunPierre
Master
Master

Maybe this;

[Temp_interim.nps_starter_pack];
NoConcatenate
LOAD DATE(DATE#(week_date,'DD-MM-YYYY'),'MM-DD-YYYY') as weekdate,
QTY_DISPENSED as NPS,
'SD_starter_pack_NPS' as Flag

resident interim.SD_final;
Where wildmatch(NDC_NBR,'000123456') and not wildmatch(ACCOUNT_NAME,'*BLOCKED*');

NoConcatenate
interim.nps_starter_pack:
LOAD weekdate,
Flag,
SUM(NPS) as NPS,

resident [Temp_interim.nps_starter_pack]
Group by weekdate,Flag;
Order by weekdate,Flag;
Drop table [Temp_interim.nps_starter_pack];

Vishal
Contributor II
Contributor II
Author

Thanks  @BrunPierre , It worked! 

Some syntax here and there, and Group by and Order by would not work together. But, I got the idea. Thanks again!