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

Announcements
Solving the Informatica Dilemma: On-Demand Briefing - Watch On Demand!
cancel
Showing results for 
Search instead for 
Did you mean: 
DMilchev
Contributor II
Contributor II

WeekName() Set Expression Does Not Work For Range

Hello, 

I am having issues with Set Expression using field for Week Year. My expression is: 

{<WeekYear = {">=2024/10<=2024/11"}>}

SUM(1)

The field WeekYear is created in my MasterCalendar  as WeekName([$(DateField)]) as $(Prefix)WeekYear and the format of the field is YYYY/WW ex. 2024/10;

 

When I write the Set Expression for searching a range like ">=2024/10<=2024/11" it does not work. Meanwhile, Qlik is correctly searching a range for field MonthYear which is formated as MM.YYYY. 

{<[Month Year] = {">=05.2024<=10.2024"}>}

SUM(1)

Labels (2)
1 Solution

Accepted Solutions
DMilchev
Contributor II
Contributor II
Author

Ok, just checked the documentation again for the function weekname() and understood why it is not working. The underlying numeric value of the weekname() corresponds to a timestamp of the first millisecond of the first day of the week containing date.

That is why if I use in my set expression: {<WeekYear = {">=2024-01-01<=2024-02-15"}>} it works properly. We need to pass a date in the range search because this is the underlying numeric/date data type of the weekname() function. 

 

Screenshot 2025-03-22 150656.png

View solution in original post

3 Replies
rubenmarin

Hi, I'm not sure if the dot version is working because it's like a number, Do you have data for other years in that sample?

Anyway, for dates I usually add a field in the calendar table in numeric format, and use that numeric fields in set analysis, in example, for WeekYear I would have a YearWeekNum field, with values like 202405, 202410, 202411... where the numeric comparison for >= or <= always works

DMilchev
Contributor II
Contributor II
Author

Hi, 

Thanks for responding!

So Qlik is interpreting both fields WeekYear (YYYY/WW ) and MonthYear (MM.YYYY) as numeric and date but the numeric composition for ">=" does not work for WeekYear in set expression  while it works fine for MonthYear. For me it is strange that the field WeekYear which is interpreted as numeric cannot use the range search. 

Screenshot 2025-03-22 145345.png

Screenshot 2025-03-22 145549.png

DMilchev
Contributor II
Contributor II
Author

Ok, just checked the documentation again for the function weekname() and understood why it is not working. The underlying numeric value of the weekname() corresponds to a timestamp of the first millisecond of the first day of the week containing date.

That is why if I use in my set expression: {<WeekYear = {">=2024-01-01<=2024-02-15"}>} it works properly. We need to pass a date in the range search because this is the underlying numeric/date data type of the weekname() function. 

 

Screenshot 2025-03-22 150656.png