Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
newqlikie
Creator
Creator

Problem with NetWorkDays() by including holidays

Hi everybody,

I try to get the networkdays for the last year, beginning with the latest loaded date. If I do not include the holidays, the function is working well.

If I include the holidays, the days will not change.

Here is my function, which is added to a textbox:

=NetWorkDays((makedate(year(max(Datum))-1, Month(max(Datum)), Day(Max(Datum)))), max(Datum), Feiertage)

The "Feiertage" is loaded in the script as follows:

tblFeiertage:
crosstable(FTJahr,FeierTG,1)
LOAD Beschreibung,
[2010],
[2011],
[2012],
[2013],
[2014],
[2015],
[2016],
[2017],
[2018],
[2019],
[2020],
[2021],
[2022],
[2023],
[2024],
[2025],
[2026],
[2027],
[2028],
[2029],
[2030]
FROM
F:\QlikView\Anwenderdateien\FeiertageDE.xls
(biff, embedded labels, table is Tabelle1$);

load concat(date(FeierTG), ',') as Feiertage
resident tblFeiertage;

What do I do wrong? Can anybody help me in this problem?

I really appreciate your help.

Regards,

NewQlikie

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

In case it's useful, attached is an example of setting up custom firstworkdate and networkdays functions with a holiday list from a data source. Below is the relevant portion of the script:

Holidays:
LOAD * INLINE [
Holiday
3/15/2010
3/10/2010
2/15/2010
1/1/2010
];

AllHolidays:
LOAD concat(num(Holiday),',') as AllHolidays RESIDENT Holidays;
LET customfirstworkdate = 'firstworkdate($1,$2,' & peek('AllHolidays') & ')';
LET customnetworkdays = 'networkdays($1,$2,' & peek('AllHolidays') & ')';
DROP TABLE AllHolidays;

View solution in original post

4 Replies
Miguel_Angel_Baeyens

Hello,

I think that you only need to pass the values in the field to a variable than can be expanded to an actual string, that is what NetWorkDays() is expecting. So try

load concat(date(FeierTG), chr(39) & ',' & chr(39)) as Feiertageresident tblFeiertage; LET vFeiertage = chr(39) & Peek('Feiertage', 0) & chr(39); // chr(39) is the single quote


Check that the dates are returned as strings 'DD/MM/YYYY' and that the function works fine.

Hope this helps

EDIT: Using LET instead of SET works.

johnw
Champion III
Champion III

In case it's useful, attached is an example of setting up custom firstworkdate and networkdays functions with a holiday list from a data source. Below is the relevant portion of the script:

Holidays:
LOAD * INLINE [
Holiday
3/15/2010
3/10/2010
2/15/2010
1/1/2010
];

AllHolidays:
LOAD concat(num(Holiday),',') as AllHolidays RESIDENT Holidays;
LET customfirstworkdate = 'firstworkdate($1,$2,' & peek('AllHolidays') & ')';
LET customnetworkdays = 'networkdays($1,$2,' & peek('AllHolidays') & ')';
DROP TABLE AllHolidays;

newqlikie
Creator
Creator
Author

Hi John,

thank you very much. It worked.

Regards,

newqlikie
Creator
Creator
Author

Hi Miguel,

thanks a lot for your answer, but I could not solve the problem with your suggestion.

I finally fixed it with John's suggestion.

Regards