EnumList: Filter values based on another EnumList

Hello,

I wonder if it is possible to filter a EnumList dropdown based on another Enumlist dropdown.

Objective:
I’m working on a App for hotels and we want to select a collection of Hotels
Dropdown 1: Hotel Categories
Dropdown 2: Hotels

Hotel Categories is a EnumList which describes if the hotel is a 4* , 5* hotel, etc.
The user can select one or many options here.

Hotel Categories should filter Hotels EnumList dropdpwn

Example:
I tried the following in order to get the list of Hotels that have any of the selected Categories.

Hotel Categories: {4 *, 5 *}
Hotel:

SELECT(Hotel[hotelName],
(IN(Hotel[hotelCateogoria], [_THIS].[hotelCateogoria]))
,TRUE)

The problem:

The above script works when the values in the field hotelCategorie has 2 or more items selected.
However, if I only select one hotel Category, it returns nothing.

Thanks for any suggestion.

UPDATE

I’m guessing the problem is related to the fact that if Hotel Categories only has 1 value, the second parameter of the IN() function is no longer a List.

If that is the case I’m attempting this approach, with no luck yet

SELECT(Hotel[hotelName],
(IN(Hotel[hotelCateogoria], 
IF(COUNT(SPLIT([_THIS].[hotelCateogoria], ","))  = 1, LIST([_THIS].[hotelCateogoria]), [_THIS].[hotelCateogoria] )))
,TRUE)

Maybe you could try in the Valid_if of the second dropdown [Hotel]

SELECT(Hotel[hotelName],
IN([hotelCateogoria], [_THISROW].[hotelCateogoria]))

Edit: Assumes the column [hotelCateogoria] in the table “Hotel” is text or enum type.

1 Like

Hi, thanks for the reply.

Indeed [hotelCateogoria] is of text type, that is correct.

Here is a small view of the Hotel table.

About the suggestion, I tried it but still couldn’t get the Hotel EnumList to populate when [hotelCategoria] only has one selected value.

Are all columns in the same table? Meaning are you trying to apply these dropdowns on the same table and results are also to be filtered from the same table “Hotel”
Could you please elaborate?

1 Like

This design has 2 tables:

Table 1: Hotel
→ Column [hotelCategoria]
→ Column [hotelName]

Table 2: CotizaHotel
Is in this table that we are looking to filter the [hotelName]'s based on the [hotelCategoria]

CotizaHotel
→ Column [hotelCategoria]
→ Column [hotelList] (Here we will show the [hotelName] List)

Valid If
Valid If constrain is being applied to CotizaHotel[hotelList] based on the values of CotizaHotel[hotelCategoria]

I hope this helps

Thank you. Hope you are trying the suggested expression in the valid_if of the [hotelList] in CotizaHotel.

The expression then will show an enumlist of hotel names pulled in from Hotel table in the [hoteList] column of the CotizaHotel table.

1 Like

Thanks, I tried that updated valid_if

SELECT(Hotel[hotelName],
(IN(Hotel[hotelCateogoria], [_THISROW].[hotelCateogoria]))
,TRUE)

However it produces the same result:
When 2 or more [hotelCategoria] are selected, the [hotelList] EnumList is populated with the [hotelName] values.
But if only 1 [hotelCategoria] is selected, [hotelList] doesn’t appear/show anything.

Hi

I requested to try

Could you please update any specific reason you are adding Hotel before [hotelCateogoria] as highlighted below?

1 Like

That was it!

Under my understanding this was being read like this:
Bring me all the [hotelCategoria]s from Hotel table that are equal to the [hotelCategoria] values inside [_THISROW].

SELECT(Hotel[hotelName],
(IN(**Hotel[hotelCategoria]**, [_THISROW].[hotelCateogoria]))
,TRUE)

It made sense in my head so I’m not really sure why it works when I remove the Hotel from Hotel[hotelCategoria].

1 Like

No problem. Good to know it works.

The syntax of SELECT() and IN() is such that one does not need to again include table name in SELECT() qualifying parameter or while giving the first parameter in IN().

The help article on SELECT() and IN() have some excellent examples. I request you to refer, just in case you have not.

2 Likes