Query EnumList into one List

Hi, the Bookings[Room] contain EnumLIST is there a way can can query into a list?

(SELECT(Bookings[Rooms],AND([_THISROW].[Checkin]<=[Checkin],[_THISROW].[Checkout]>[Checkin]))

  • SELECT(Bookings[Rooms],AND([_THISROW].[Checkin]<[Checkout],[_THISROW].[Checkout]>=[Checkout]))

  • SELECT(Bookings[Rooms],AND([_THISROW].[Checkin]>=[Checkin],[_THISROW].[Checkout]<=[Checkout]))

  • SELECT(Bookings[Rooms],AND([_THISROW].[Checkin]<=[Checkin],[_THISROW].[Checkout]>=[Checkout]))
    )

from the code above I got this as a result

3X_9_c_9c377e9abb7954c372d93dbb03ab531b157bbe09.png

instead I want out come as one list.

Please help

Solved Solved
0 4 140
1 ACCEPTED SOLUTION

Hi @Tech_Service

In your expression, that I allow myself to indent in order to add more readability:

SPLIT(
  SELECT(Bookings[Rooms],
    AND([_THISROW].[Checkin]<=[Checkin],
        [_THISROW].[Checkout]>[Checkin]))
)
+ SPLIT(
  SELECT(Bookings[Rooms],
    AND([_THISROW].[Checkin]<[Checkout],
        [_THISROW].[Checkout]>=[Checkout]))
)
+ SPLIT(
  SELECT(Bookings[Rooms],
    AND([_THISROW].[Checkin]>=[Checkin],
        [_THISROW].[Checkout]<=[Checkout]))
)
+ SPLIT(
  SELECT(Bookings[Rooms],
    AND([_THISROW].[Checkin]<=[Checkin],
        [_THISROW].[Checkout]>=[Checkout])))
)

There are various things that attract my attention. If you donโ€™t mind, I would like to provide some corrections/improvements to it:

  1. According to the doc:
    SPLIT() | AppSheet Help Center
    delimiters are missing in your expression. This is curious you didnโ€™t get any error message, as the delimiter is not optional.
  2. At this stage, and if you use only a SELECT expression inside of your SPLIT() ==> you can get rid of SPLIT part. SPLIT() is useful if you deal with some EnumList expression, for technical reasons (text separated with " , "), and used with CONCATENATE() expression as well.
  3. in your expression, all SELECT expressions are based on the same table and same column. You should use OR() expression inside one single SELECT statement.

So, your expression would become:

SELECT(Bookings[Rooms],
  OR(
    AND([_THISROW].[Checkin]<=[Checkin],
        [_THISROW].[Checkout]>[Checkin]
    ),
    AND([_THISROW].[Checkin]<[Checkout],
        [_THISROW].[Checkout]>=[Checkout]
    ),
    AND([_THISROW].[Checkin]>=[Checkin],
        [_THISROW].[Checkout]<=[Checkout]
    ),
    AND([_THISROW].[Checkin]<=[Checkin],
        [_THISROW].[Checkout]>=[Checkout]
    )
  )
)

For reference:

View solution in original post

4 REPLIES 4

Aurelien
Google Developer Expert
Google Developer Expert

Hi @Tech_Service

Here:
https://community.appsheet.com/search?q=merge%20enumlist

Can you change the category of your post into โ€œQuestionsโ€ please ? It is more relevant.

Thank you ! This really help!

Thank you @Aurelien

I ended up using SPLIT() to each Select then Add them up later like this.

SPLIT(SELECT(Bookings[Rooms],AND([_THISROW].[Checkin]<=[Checkin],[_THISROW].[Checkout]>[Checkin])))+ SPLIT(SELECT(Bookings[Rooms],AND([_THISROW].[Checkin]<[Checkout],[_THISROW].[Checkout]>=[Checkout])))+ SPLIT(SELECT(Bookings[Rooms],AND([_THISROW].[Checkin]>=[Checkin],[_THISROW].[Checkout]<=[Checkout])))+ SPLIT(SELECT(Bookings[Rooms],AND([_THISROW].[Checkin]<=[Checkin],[_THISROW].[Checkout]>=[Checkout])))
)

Hi @Tech_Service

In your expression, that I allow myself to indent in order to add more readability:

SPLIT(
  SELECT(Bookings[Rooms],
    AND([_THISROW].[Checkin]<=[Checkin],
        [_THISROW].[Checkout]>[Checkin]))
)
+ SPLIT(
  SELECT(Bookings[Rooms],
    AND([_THISROW].[Checkin]<[Checkout],
        [_THISROW].[Checkout]>=[Checkout]))
)
+ SPLIT(
  SELECT(Bookings[Rooms],
    AND([_THISROW].[Checkin]>=[Checkin],
        [_THISROW].[Checkout]<=[Checkout]))
)
+ SPLIT(
  SELECT(Bookings[Rooms],
    AND([_THISROW].[Checkin]<=[Checkin],
        [_THISROW].[Checkout]>=[Checkout])))
)

There are various things that attract my attention. If you donโ€™t mind, I would like to provide some corrections/improvements to it:

  1. According to the doc:
    SPLIT() | AppSheet Help Center
    delimiters are missing in your expression. This is curious you didnโ€™t get any error message, as the delimiter is not optional.
  2. At this stage, and if you use only a SELECT expression inside of your SPLIT() ==> you can get rid of SPLIT part. SPLIT() is useful if you deal with some EnumList expression, for technical reasons (text separated with " , "), and used with CONCATENATE() expression as well.
  3. in your expression, all SELECT expressions are based on the same table and same column. You should use OR() expression inside one single SELECT statement.

So, your expression would become:

SELECT(Bookings[Rooms],
  OR(
    AND([_THISROW].[Checkin]<=[Checkin],
        [_THISROW].[Checkout]>[Checkin]
    ),
    AND([_THISROW].[Checkin]<[Checkout],
        [_THISROW].[Checkout]>=[Checkout]
    ),
    AND([_THISROW].[Checkin]>=[Checkin],
        [_THISROW].[Checkout]<=[Checkout]
    ),
    AND([_THISROW].[Checkin]<=[Checkin],
        [_THISROW].[Checkout]>=[Checkout]
    )
  )
)

For reference:

Top Labels in this Space