Filtering date-range with numeric "slider"-input

hi,

i want to filter โ€œdate/timeโ€-range" of a โ€œsliceโ€ with โ€œsliderโ€-Input (numeric value)

e.g. date-range = the last 30 days (slider = 30)
date-range = the last 7 days (slider = 7)

step 1: adding a โ€œvcโ€ with formula for calulation number of days from โ€œTodayโ€
HOUR (TODAY() - DATE([Date/Time])) / 24
table-name: โ€œweightโ€
vc-column-name: โ€œdaysโ€
no problem!

step 2: generating numbers between 1 - 30 with slider in a separate table (only one row with value of slider-input)
table-name= โ€œselectโ€
column-name = โ€œdaysโ€
no problem!

step 3:
filtering โ€œsliceโ€ with โ€œslider-inputโ€

setting up โ€œrow-filter-conditionโ€ of โ€œsliceโ€: [weight].[days] >= [select].[days]

this does not work because i cannot select table โ€œ[select].[days].โ€ for โ€œrow-filter-conditionโ€.

how can i achieve this? - many thanks in advance for your help!

0 3 169
3 REPLIES 3

Bsed on understanding of your requirement, you may wish to note and try the following

In general, you may wish to avoid naming tables and columns same as those of AppSheet functions. There is table name Select and column name as days. AppSheet has functions SELECT() and DAY(). So a SELECT() on select table with days column would look like SELECT(Select[days], DAY([Date])โ€ฆ)
It can be confusing to debug and at times may throw error as it could clash with Appsheet reserved words. AppSheet is very generous with element name selection and allows most such words, but better to avoid if possible.

So renaming the step 2 table as โ€œSliderInputโ€ in place of โ€œselectโ€ and [days] as [SliderDays] ( assumed to be number type column) , you could try the below slice expression

A. If there is just one data row in the โ€œSliderInputโ€ table

DATE([DATE/TIME] >= TODAY() - ANY( SliderInput[SliderDays])

B. If there are multiple rows in the โ€œSliderInputโ€ table, say one for each user, you may need to use a SELECT() statement with suitable argument as shown below

DATE([DATE/TIME] >= TODAY() -ANY(SELECT( SliderInput[SliderDays], [[Email]=USEREMAIL()))

The expression may need minor modifications based on your exact requirement. The above will return the rows with dates in the past those many days from today as set on the slider.

Edit: Added any to the second expression.

hello Suvrutt_Gurjar,

i can learn a lot from from your explanation:
a) naming โ€œtablesโ€ and โ€œcolumnsโ€
b) function โ€œany()โ€ โ€ฆ

i will test it out - thank you so much !!!

You are welcome. Please take a look at ANY() function article just in case you have not

In fact your mention of ANY() reminded me that there was ANY() required in the second suggested expression as well. Have edited the first post accordingly.

Top Labels in this Space