Can someone tell me why this works?

I needed to make a calendar view where you can select any one or many of a series of teams to view their upcoming events. I used a quick edit detail view to filter the events.

However when I was testing the expression for my slice, I realized If I do this:

IF(
COUNT(OmniBox[Calendar Selection])=1,
IN([Team], INDEX(OmniBox[Calendar Selection], 1)),
IN([Team], INDEX(OmniBox[Calendar Selection], 2))
)


App sheet will continue the same behavior for items 3, 4, 5, 6 and so on. So with this small expression it inferred that I wanted to expand that behavior to other selections? If that makes sense?

Is this on purpose? I like it if so, but just was curious why this works?

0 4 135
4 REPLIES 4

OmniBox table has only a single record, right? Where [Calendar Selection] is an EnumList of [team] values? 

Assuming yes, there's a lot wrong with your expression. Here's what I imagine you should be using

IN( [Team] , SPLIT( TEXT( AmniBox[Caeldnar Selection] ) , " , " ) )

 

App sheet will continue the same behavior for items 3, 4, 5, 6 and so on. So with this small expression it inferred that I wanted to expand that behavior to other selections? If that makes sense?


No, that doesn't make any sense.

 

Yea one record/ cell that affects that specific parameter but it is an enum list. So can be one team or many teams.

It controls which team's events the user is seeing in the calendar.
That could be just wanting to see one teams events or all the teams you're in.

The expression I provided above it doesn't stop at 2 list values event though it's a rudimentary IF() expression.. It acts  exactly as the expression you wrote.
It automatically splits it and keeps going, as many or few teams as I want or need.

Like the expression works as I wanted it, but not how I expected it to?

When none are selected it shows no events.

An expression of table[EnumList] returns a List-of-Lists. 

An expression COUNT( table[column] ) returns the record count in the table, no matter what you specify as the column. Even if the column is blank in some records. Your IF expression was always returning the if-result, because you always had a single record.

INDEX( table[enumlist] , 1 ) will return the enumlist value from the first record of the table. However this has not worked appropriately in the past, and Appsheet often has these "yo-yo" types bugs that sort of seem to sometimes get "fixed" but then are "broken" later on. I highly recommend not counting on being able to accurately use INDEX or ANY or IN or any other list-related expressions when working with Lists-of-Lists. Always be explicit about what you want returned.

So actually your expression is sort of equivalent to mine, but it's misleading and not reliable.

Thank you so much for this info. I had a feeling it was something like this. Great stuff and helpful concise explanation.

Top Labels in this Space