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

Grouping Historical Data into Last Week & Keeping Current and Future Weeks' Data as it is

Hi Qlik Community, 

I have two types of Backlog Quantities that I would like to compare but they both have different Fiscal Weeks. I have mapped the two dates together in the data load script, but am facing an issue when I'm trying to group the historical weeks' data into one particular week while keeping the rest of the weeks as they are. 

For example, I have the below two tables looking at Mkt Part Num, Customer and Ship To Country by Week (ie 201827 - Year 2018, Week 27). I've mapped the two weeks together to obtain the Final Output, but I would like to combine the historical weeks data together into one particular week for example, to combine all the data that is prior to Week 201908 into 201908 while the rest of the weeks remain. Does anyone have any idea how to solve this in the script? I would also need to do this without affecting other reports that are using the same script. I was thinking maybe create a filter that I could use in the expression instead? 

#1: Backlog Type A 

Mkt Part Num

CustomerShip to Country201827201845201908201909201910201911201912201913
ABCAdamGERMANY   24003000240018002400
ABCAlanBRAZIL   960720360  
ABCBelleINDIA12001200      
ABCMaryMALAYSIA  120012001200120012001200

 

#2: Backlog Type B

Mkt Part NumCustomerShip to Country201827201845201907201909201910201911201912201914
ABCAdamGERMANY18003000  240030001800 
ABCAlanBRAZIL 480  480720  
ABCBelleINDIA120012002400     
ABCMaryMALAYSIA   1200 120012001200

 

Current Final Output:

Mkt Part Num

CustomerShip to CountryBacklog Type201827201845201907201908201909201910201911201912201913201914
ABCAdamGERMANYA    24003000240018002400 
ABCAdamGERMANYB18003000   240030001800  
ABCAdamGERMANYDelta1800480048004800240018002400240000
ABCAlanBRAZILA    960720360   
ABCAlanBRAZILB 480   480720   
ABCAlanBRAZILDelta0480480480-480-720-360-360-360-360
ABCBelleINDIAA12001200        
ABCBelleINDIAB120012002400       
ABCBelleINDIADelta0024002400240024002400240024002400
ABCMaryMALAYSIAA   120012001200120012001200 
ABCMaryMALAYSIAB    1200 12001200 1200
ABCMaryMALAYSIADelta000-1200-1200-2400-2400-2400-3600-2400

 

Desired Final Output: 

Here you will see that the data from weeks 201827 - 201908 above have been combined into 201908 while the rest of the weeks' data remain unchanged. 

Mkt Part NumCustomerShip to CountryBacklog Type201908201909201910201911201912201913201914
ABCAdamGERMANYA 24003000240018002400 
ABCAdamGERMANYB4800 240030001800  
ABCAdamGERMANYDelta4800240018002400240000
ABCAlanBRAZILA 960720360   
ABCAlanBRAZILB480 480720   
ABCAlanBRAZILDelta480-480-720-360-360-360-360
ABCBelleINDIAA2400      
ABCBelleINDIAB4800      
ABCBelleINDIADelta2400240024002400240024002400
ABCMaryMALAYSIAA120012001200120012001200 
ABCMaryMALAYSIAB 1200 12001200 1200
ABCMaryMALAYSIADelta-1200-1200-2400-2400-2400-3600-2400

 

Below is my current script: 

Backlog_All:

Load

*,

FROM [Lib:xxx] (qvd);

CRS:
Mapping Load
OrderID,
CRS_WEEK
Resident Backlog_All;

RS:
Mapping Load
OrderID,
RS_WEEK
Resident Backlog_All;

Final_Backlog_All:
Load
*,
ApplyMap('CRS',OrderID, 'OTHER') as FiscalWeek,
'CRS' as BacklogType,
1 as Status
Resident Backlog_All;

Load
*,
ApplyMap('RS',OrderID, 'OTHER') as FiscalWeek,
'RS' as BacklogType,
0 as Status
Resident Backlog_All;

 

Drop table Backlog_All;

 

Thanks,

Elin

 

Hi @sunny_talwar  would you be able to help with this? thanks 

2 Replies
sunny_talwar

Why did you only decide to remove 201827 - 201908 and not another date range? I am trying to understand the logic behind this?

elintham
Contributor
Contributor
Author

Hi Sunny, 

 

The data under 201827 - 201908 wasn't removed but rather combined under 201908. So what I did manually to achieve the Final Desired Output was to sum the Types A & B Backlog for all past weeks under 201908. For example: ABC/Adam/Germany/Type B - I summed 1800 & 3000 under weeks 201827 & 201845 and put that under 201908. 

Ideally we just want to combine the data into a particular week for example last week so that we don't need to show so many weeks in the data. Hope that clarifies your question.