Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Strange problem with Set_Expression

Hi,

I have, in the course of fixing a larger issue, come across one relatively small, but annoying thing:

- I have a master_calendar in a qvs file that is loaded into every app.

- This master_calendar is currently for one year only

- In the calendar, there is a binary field returning 1 for working_days (Mo-Fri) and 0 for weekends. Public holidays are not accounted
   for.

- Based on this, I have two variables: Days_YTD (all days) and Workdays_YTD (Mo-Fri only).

=> The code for these is as follows:

COUNT({1<%Datum = {"$(= '>=' & makedate(year(today()), 1, 1))"}, %Datum = {"$(= '<' & DATE(v_today_num))" }>} Werktag)

[for all days YTD]

SUM({1<%Datum = {"$(= '>=' & makedate(year(today()), 1, 1))"}, %Datum = {"$(= '<' & DATE(v_today_num))" }>} Werktag)

[for the workdays]

Strangely, when I edit the qvs file to make the calendar run for three years (by editing the start_date, incl. testing the code in a textbox)

=> The variables suddenly change and display about three times the nr. of days?!

There must be some error in my set_expressions - but which? I can't spot it.

Can anybody help me, please?

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You shouldn't use the same field twice within the same set modifier. Combine your two date ranges into one search expression:

=COUNT({1<%Datum = {">=$(=makedate(year(today()), 1, 1))<$(=DATE(v_today_num))" }>} Werktag)

View solution in original post

2 Replies
swuehl
MVP
MVP

You shouldn't use the same field twice within the same set modifier. Combine your two date ranges into one search expression:

=COUNT({1<%Datum = {">=$(=makedate(year(today()), 1, 1))<$(=DATE(v_today_num))" }>} Werktag)

datanibbler
Champion
Champion
Author

Cool! Didn't know that yet.

Thanks a lot!

Best regards,

DataNibbler