web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Update Context variabl...
Power Apps
Unanswered

Update Context variable using If not working

(0) ShareShare
ReportReport
Posted on by

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.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,075 Most Valuable Professional on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard