dateamazon-quicksightweek-number

Quicksight displays wrong week number between two years


I use this function to get week number in quicksight

dateDiff(truncDate('YYYY', {Date de Souscription}), {Date de Souscription}, 'WK')+1

This works correctly for 2023:

week number 2023

As you can see on this picture, this works normally, weeks start on Sunday in quicksight and weeknumber is correct

Now when switching to 2024, with the same formula, weeknumber seems to start on the first day of 2024 and not on sunday:

week number 2024

Now as you can see, the 7 of january is a Sunday and should then be the start of a new week but its not, meaning the same formula defines the week number differently depending on the year.

So I would need a solution to makes the weeknumber works same as it would work in Sheets/Excell, meaning a weeks always start on sunday. Meaning that first week of 2024 should go from first of january to six of january, even if it makes a "6 days week"


Solution

  • Please try this once.

    dateDiff(truncDate("WK", truncDate('YYYY', {Date_de_Souscription})), {Date_ de_Souscription}, 'WK')+1