Current week and Last week

Hello guys !

Can someone help me please ? I want to create two slices :

  1. A slice who show the records of current week
  2. A slice who show the records of last week

How can I do that ? Do you have an expression for that ?

Thank you.

Please try

  • A slice who show the records of current week -

WEEKNUM([Date Column])= WEEKNUM(TODAY())

  • A slice who show the records of last week -

WEEKNUM([Date Column])= WEEKNUM( (EOWEEK(TODAY()) - 7) )

AppSheet’s week is from Sunday to Saturday in all WEEK expressions.

Edit: made a change in second expression

4 Likes

Thank’s @Suvrutt_Gurjar for your answer, I’m going to try it right now !

1 Like

It works perfectly, thank you @Suvrutt_Gurjar :hugs:

2 Likes

You are welcome. Please do test well for weekends during the year end when the year flips but the weeks remain same,

1 Like

Alright. I’ll be careful and make an adaptation just in case. Thank you

2 Likes

One expression shorter :slight_smile: EOWEEK([Date Column])=EOWEEK(TODAY() - 7). If you use dates more than from one year, the WEEKNUM() doesn’t work correctly.

4 Likes

Supporting what @Aleksi has mentioned, you can get the correct WEEKNUM with below expression:

FLOOR(
	(10 +
	IF(
		MOD(YEAR([TIMESTAMP]), 4) = 0,
		INDEX({0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335},MONTH([TIMESTAMP])),
		INDEX({0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334},MONTH([TIMESTAMP]))
	) + DAY([TIMESTAMP]) - (WEEKDAY([TIMESTAMP]) - 1)) / 7
)
2 Likes

so monday to sunday week is behind tricks only??

1 Like