Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
sevvalk
Creator
Creator

Hi

Hi, the main code is like this.

SET ThousandSep='.';
SET DecimalSep=',';
SET MoneyThousandSep='.';
SET MoneyDecimalSep=',';
SET MoneyFormat='₺#.##0,00;-₺#.##0,00';
SET TimeFormat='hh:mm:ss';
SET DateFormat='D.MM.YYYY';
SET TimestampFormat='D.MM.YYYY hh:mm:ss[.fff]';
SET FirstWeekDay=0;
SET BrokenWeeks=1;
SET ReferenceDay=0;
SET FirstMonthOfYear=1;
SET CollationLocale='tr-TR';
SET CreateSearchIndexOnReload=1;
SET MonthNames='Oca;Şub;Mar;Nis;May;Haz;Tem;Ağu;Eyl;Eki;Kas;Ara';
SET LongMonthNames='Ocak;Şubat;Mart;Nisan;Mayıs;Haziran;Temmuz;Ağustos;Eylül;Ekim;Kasım;Aralık';
SET DayNames='Pzt;Sal;Çar;Per;**bleep**;Cmt;Paz';
SET LongDayNames='Pazartesi;Salı;Çarşamba;Perşembe;Cuma;Cumartesi;Pazar';
SET NumericalAbbreviation='3:k;6:M;9:G;12:T;15:P;18:E;21:Z;24:Y;-3:m;-6:μ;-9:n;-12:p;-15:f;-18:a;-21:z;-24:y';

 

I print which week today is in a text file. With the week(today()) formula, but today comes as week 0. Where could there be a mistake?

1 Solution

Accepted Solutions
Scotchy
Partner - Creator
Partner - Creator

The issue with the week(today()) formula in Qlik Sense returning "week 0" could be due to the configuration of the week-related settings in your script. Based on the settings you've provided, let's analyze the potential causes and solutions:

  1. FirstWeekDay Setting: You've set SET FirstWeekDay=0;. In Qlik Sense, FirstWeekDay=0 means that the week starts on Monday. This should be correct for most standard calendar configurations, but if your business logic defines a different start day for the week, you might need to adjust this.

  2. BrokenWeeks Setting: You've set SET BrokenWeeks=1;. This setting determines how Qlik Sense deals with weeks that span across years. When set to 1, weeks are not split at the year change, which means the days from the previous year could be counted as part of the first week of the new year. If this setting doesn't align with your calendar logic, it could cause unexpected week numbering.

  3. ReferenceDay and FirstMonthOfYear Settings: These are set to SET ReferenceDay=0; and SET FirstMonthOfYear=1;, respectively. These should typically not affect the week calculation unless there's a specific business calendar being used that differs from the Gregorian calendar.

Given these points, here are a few steps to troubleshoot and resolve the issue:

  • Verify the Current Date: Ensure that the today() function is returning the current date as expected. You can simply create a text object to display the output of today().

  • Check Week Calculation: Test the week(today()) function in a separate text object without any other script settings applied, to see if it returns the correct week number.

  • Review Calendar Settings: If your business uses a non-standard calendar (like a 4-4-5 retail calendar), the week calculation might need to be adjusted accordingly.

  • Script Execution Order: Ensure that these settings are being executed before any data load or manipulation that uses date functions. Settings should typically be at the very beginning of your script.

If these steps don't resolve the issue, it might be helpful to look into any additional script settings or data model complexities that could be impacting the week calculation.

View solution in original post

1 Reply
Scotchy
Partner - Creator
Partner - Creator

The issue with the week(today()) formula in Qlik Sense returning "week 0" could be due to the configuration of the week-related settings in your script. Based on the settings you've provided, let's analyze the potential causes and solutions:

  1. FirstWeekDay Setting: You've set SET FirstWeekDay=0;. In Qlik Sense, FirstWeekDay=0 means that the week starts on Monday. This should be correct for most standard calendar configurations, but if your business logic defines a different start day for the week, you might need to adjust this.

  2. BrokenWeeks Setting: You've set SET BrokenWeeks=1;. This setting determines how Qlik Sense deals with weeks that span across years. When set to 1, weeks are not split at the year change, which means the days from the previous year could be counted as part of the first week of the new year. If this setting doesn't align with your calendar logic, it could cause unexpected week numbering.

  3. ReferenceDay and FirstMonthOfYear Settings: These are set to SET ReferenceDay=0; and SET FirstMonthOfYear=1;, respectively. These should typically not affect the week calculation unless there's a specific business calendar being used that differs from the Gregorian calendar.

Given these points, here are a few steps to troubleshoot and resolve the issue:

  • Verify the Current Date: Ensure that the today() function is returning the current date as expected. You can simply create a text object to display the output of today().

  • Check Week Calculation: Test the week(today()) function in a separate text object without any other script settings applied, to see if it returns the correct week number.

  • Review Calendar Settings: If your business uses a non-standard calendar (like a 4-4-5 retail calendar), the week calculation might need to be adjusted accordingly.

  • Script Execution Order: Ensure that these settings are being executed before any data load or manipulation that uses date functions. Settings should typically be at the very beginning of your script.

If these steps don't resolve the issue, it might be helpful to look into any additional script settings or data model complexities that could be impacting the week calculation.