Change row filter condition for a slice based on user input

Iโ€™m filtering a slice based on user input within a dashboard as follows:
AND(ANY(Filter[Observation Type]) = [Observation Type], ANY(Filter[Description]) = [Description], ANY(Filter[Work Status]) = [Work Status], ANY(Filter[Start Date]) <= [Date and time], ANY(Filter[End Date]) >= [Date])

This expression works fine. But I want the user to have a choice whether or not to filter on โ€œDescriptionโ€. He would choose Yes or No to โ€œDo you want to filter on Description?โ€.
If he chooses NO the expression would bring ALL Description types. I believe I would need to put together the above expression with another expression that doesnโ€™t filter on Description, based on an IF statement.

Can this be done in one row filter expression and if so how?

Thanks
Bob

3 8 2,816
8 REPLIES 8

Steve
Platinum 4
Platinum 4

Based on your expression, I would expect a blank Filter[Description] value to โ€œbring ALL Description typesโ€. Does it not?

Using Slices Iโ€™m trying to create a row filter condition (Yes/No). To avoid confusion with the AppSheet function โ€œFilterโ€ I changed the table name Filter to FilterTable.

This formula works:
AND(ANY(FilterTable[Observation Type]) = [Observation Type], ANY(FilterTable[Description]) = [Description], ANY(FilterTable[Work Status]) = [Work Status], ANY(FilterTable[Start Date]) <= [Date and time], ANY(FilterTable[End Date]) >= [Date])

The following formula doesnโ€™t work. It gives the error - Unable to find column โ€˜FilterDescโ€™. This doesnโ€™t make sense to me since FilterDesc is a column of FilterTable like the other columns in the formula.

IFS(
[FilterDesc] = โ€œYesโ€,
(AND(ANY(FilterTable[Observation Type]) = [Observation Type], ANY(FilterTable[Description]) = [Description], ANY(FilterTable[Work Status]) = [Work Status], ANY(FilterTable[Start Date]) <= [Date and time], ANY(FilterTable[End Date]) >= [Date])),

[FilterDesc] = โ€œNoโ€,
(AND(ANY(FilterTable[Observation Type]) = [Observation Type], ANY(FilterTable[Work Status]) = [Work Status], ANY(FilterTable[Start Date]) <= [Date and time], ANY(FilterTable[End Date]) >= [Date]))
)

Iโ€™m trying to just filter for the past week. Iโ€™m not sure what expression I need to create that slice. Can you help?

Within the last 7 days:

([DateTime] > (NOW() - 7))

Since Sunday of this week:

([DateTime] > (EOWEEK(NOW()) - 7))

Since Saturday of this week:

([DateTime] > (EOWEEK(NOW()) - 8))

Hi , check your elipses

Yes, I had unnecessary () before both AND, which was not needed. I eliminated them but thatโ€™s not the problem.

My error remains - Unable to find column โ€˜FilterDescโ€™

I think you need ANY(FilterTable[Filter_Desc]) = โ€œYesโ€ (and ditto for No or just use IF with an else case).

Stylistically, I would consider writing this a bit differently. Iโ€™m assuming there is only one row in the FilterTable and its key is known. Letโ€™s say the key is โ€œ1โ€. So you could have a hidden virtual column FIlterRef in the table you are filtering with a Ref to the FilterTable and the app formula โ€œ1โ€. Then you could just do a de-reference.

IF([FilterRef].[FilterDesc] = โ€œYesโ€,
AND([FilterRef].[ObservationType] = [Observation Type),
[FilterRef].[Description] = [Description],
โ€ฆ
)
โ€ฆ else case โ€ฆ

Thanks for your help Praveen. Your first recommendation works great. Now I have a REAL interactive dashboard - see attached browser pic. Everything is live and allows drill down. Query drop downs filter key parameters needed for land management. Query results are shown in a live map and live graph, both of which can be drilled down to a specific problem report. In this case I tapped a map location which opened a specific record within the query.

There are some opportunities which Iโ€™ll discuss with your support folk - The map and chart do not always update unless they are tapped. Can sync be turned off since - updates occur without syncing, syncs are slow (Premium plan) and they syncs build up with each change in query input? Requiring sync can cause 2 people working at the same time to swap queries - not good. The chart cannot be resized. Can the chart drill down be within this single view rather than opening new views?

Thanks again
Bob Haizmann

Top Labels in this Space