How to do it...

  1. Copy and paste the following part of the script in the Data load editor. This is a list of public holidays for 2014 and 2015:
HolidayTmp: 
LOAD DATE(Date#( Date,'DD/MM/YYYY')) as Date INLINE [ 
Date 
01/01/2015 
03/04/2015 
06/04/2015 
04/05/2015 
25/05/2015 
31/08/2015 
25/12/2015 
28/12/2015 
01/01/2014 
18/04/2014 
21/04/2014 
05/05/2014 
26/05/2014 
25/08/2014 
25/12/2014 
26/12/2014 
]; 
  1. Next, we will store the list of public holidays in a variable inside the script:
ConcatTmp: 
LOAD concat(chr(39) & Date & chr(39),',') AS HolidayDates 
RESIDENT HolidayTmp; 
LET vPublicHolidays = FieldValue('HolidayDates',1); 
 
LET vCurMonth=month(today());
  1. Copy and paste the following fact table. Insert the last of the PostingDates in your table as today's date and put a sales figure against it. This is to demonstrate the use of today() in the WorkingDays calculation:
SalesTmp: 
LOAD DATE(Date#( PostingDate,'DD/MM/YYYY')) as PostingDate, 
Sales INLINE [ PostingDate, Sales 05/08/2014, 5000 04/09/2014,522 24/10/2014,400 15/11/2014,5000 24/12/2014, 822 29/12/2014, 633 02/01/2015, 1000 02/02/2015, 2000 25/03/2015,2200 25/04/2015,266 09/05/2015, 3000 18/05/2015, 4000 15/06/2015,5000 22/07/2015,456 08/09/2015,4200 26/10/2015,1875 ];
  1. Next, calculate the number of working days:
Sales: 
LOAD *, 
Month(PostingDate) as Month, 
MonthName(PostingDate) AS MonthYear,  
IF(Year(PostingDate)=Year(TODAY()) AND Month(PostingDate)=MONTH(TODAY()), 
NETWORKDAYS(MONTHSTART(today()),(Today()),
'$(vPublicHolidays)'), NETWORKDAYS(MONTHSTART(PostingDate),
MonthEnd(PostingDate), '$(vPublicHolidays)')) AS WorkingDays RESIDENT SalesTmp; DROP table SalesTmp; DROP table HolidayTmp;
  1. Load the script.
  2. On the Qlik Sense sheet, create a Table object and name it Average Monthly Sales.
  3. Add MonthYear and WorkingDays as dimensions.
  1. Add the following measure and label it as Avg Sales:
Sum(Sales)/WorkingDays 
  1. Set the number formatting for Avg Sales to Money.
  2. Under Sorting, make sure that the MonthYear field is promoted to the top.
  3. Go to Appearance | Presentation and switch off Totals.
  4. The final table object should look like this:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset