Hi,
TODAY () - “12/30/2001”: the Duration between the current Date and December 30, 2001 (a Date).
It returns the only duration Not the days. So follow the steps
HOUR (TODAY () - “12/30/2001”) /24<7.
HOUR (TODAY () - DATE([Sent Date/Time])) /24<7
Thanks for your help. I have tried and tidied up as the following. Still problematic.
AND(
OR(
CONTAINS([Recipients], USEREMAIL()),
CONTAINS([Sent By], USEREMAIL())
),
SWITCH(&FIlters[Period],“LAST WEEK”,HOUR(TODAY() - DATE([_THISROW].[Sent Date/Time]))/24 <7,“LAST MONTH”,HOUR(TODAY() - DATE([_THISROW].[Sent Date/Time]))/24<30, FALSE)
)
The expression intends to return all the messages either sent or received by me and in last week or last month. The selection criteria is recorded in a table named Filters and can be dynamically changed by user.
the error message:
Expression ‘AND( OR( CONTAINS([Recipients], USEREMAIL()), CONTAINS([Sent By], USEREMAIL() ), SWITCH(&FIlters[Period],“LAST WEEK”,HOUR(TODAY() - DATE([_THISROW].[Sent Date/Time]))/24 <7,“LAST MONTH”,HOUR(TODAY() - DATE([_THISROW].[Sent Date/Time]))/24<30, FALSE)) )’ could not be parsed due to exception: Sequence contains no elements.
What attracts my attention is your SWITCH input.
SWITCH formula can have only a value, and FIlters[Period] refers to a whole column, so will provide a list of values.
Can you try: SWITCH(ANY(&FIlters[Period]),
instead ?
Assuming the Filters table is written with the & before, and that it contains only one row.
Thanks! I just copied pasted to the Expression box. unfortunately, got the same error.
Expression ‘AND( OR( CONTAINS([Recipients], USEREMAIL()), CONTAINS([Sent By], USEREMAIL()) ), SWITCH(ANY(&FIlters[Period]), “LAST WEEK”, HOUR(TODAY() - DATE([_THISROW].[Sent Date/Time]))/24 <7, “LAST MONTH”, HOUR(TODAY() - DATE([_THISROW].[Sent Date/Time]))/24<30, FALSE ) )’ could not be parsed due to exception: Sequence contains no elements.
I can not understand what the sentence “Sequence contains no elements” means?
you are right, the filters table only has ONE row/record, which can be edited by user realtime
It works!! but I noticed that you moved [_THISROW]. the [Sent Date/Time] is the column which I assume contains multiple values. It looks Appsheet will automatically decides the work is Row by Row. If this is the case, I still learnt that many other cases still see [_THISROW], then how to decide where to use [_THISROW]?
Use [_THISROW] only within FILTER(), LOOKUP(), MAXROW(), MINROW(), and SELECT() expressions to refer to the row from which the expression was launched.
Back-references within nested queries ([_THISROW-n]) Consider a complex App formula with “nested” SELECT() expressions (SELECT() expressions within SELECT() expressions): SELECT( table[column1], … SELECT( table[column2], … SELECT( table[column3], … ) … ) … ) Let’s call the row for which this entire expression is evaluated as its App formula the Origin Row. Within this entire expression, we can refer to column values of the Origin Row by dere…