Previous week flag

 Is Previous Week =

IF(

    WEEKNUM('Date'[Date], 2) = WEEKNUM(TODAY(), 2) - 1

        && YEAR('Date'[Date]) = YEAR(TODAY()),

    1,

    0

)

What each part means

🔹 WEEKNUM('Date'[Date], 2)

  • Returns the week number of each date in your Date table
  • 2 → week starts on Monday
    • Week 1 = first week of the year

🔹 WEEKNUM(TODAY(), 2) - 1

  • Gets current week number
  • Subtracts 1 → gives previous week number

👉 Example:

  • Today → Week 16
  • Previous week → Week 15

🔹 YEAR('Date'[Date]) = YEAR(TODAY())

  • Ensures the date belongs to the current year
  • Prevents mixing weeks from different years

🔹 IF(condition, 1, 0)

  • If both conditions are TRUE → return 1
  • Else → return 0

Comments

Popular posts from this blog

Many-to-many relationship