
Announcements
I have a gallery with the "items" attribute set to a context variable, which is initially just a standard table. I'm trying to create a UI to filter the items on the gallery with two datepickers (which corresponds to the records' "desired settlement date" attribute) and three combo boxes (for three text attributes called "from", "to" and "status"). I initially tried both the combo boxes and datepickers individually to see if context variables could work for this and they did. I made a button with the word "filter" on it, and when you pressed it it would update the context variable. Testing out the datepickers, for example, I used this code for the button's on select attribute:
UpdateContext({contextVariable:Filter(TABLE, Desired_Settlement_Date >= dp_initial_date.SelectedDate, Desired_Settlement_Date <= dp_end_date.SelectedDate)})
and individually the datepickers and each combo box work fine using the code above.
However, I want to use combinations of those filtering options and not force the user to filter the records by desired settlement date if they only want to filter the records using the to and from attributes, for example. My initial thought was to do this:
If(!IsEmpty(cb_to) && !IsEmpty(cb_from) && !IsEmpty(cb_status), UpdateContext({contextVariable:Filter(TABLE, Desired_Settlement_Date >= dp_initial_date.SelectedDate,Desired_Settlement_Date <= dp_end_date.SelectedDate, To.Value in cb_to.SelectedItems.Description, From.Value in cb_from.SelectedItems.Description, Status.Value in cb_status.SelectedItems.Description)}),
IsEmpty(cb_to) && !IsEmpty(cb_from) && !IsEmpty(cb_status), ...
and basically checking every possible combination of which combo boxes were used to filter the records by the user (excluding the datepickers which are obligatory to use since I haven't figured out a way to avoid using them). I updated the above code using the same logic checking to see if different syntax would do the trick, but unfortunately I haven't found a way to make it work. I was wondering if anyone could point out my mistake or have more efficient code for doing this since 8 if conditions seems a bit much.
HI @Anonymous ,
Please consider using a Collection instead of a Variable for storing a Table and Patch the new values to it - if it does not work with that, I am happy to look at it for you.