Hi folks,
First, I'm aware that there are a lot of other posts on this particular topic, but I've looked at pretty much all of the ones I could find and am not coming up with a solid solution for my particular scenario. I'm still learning PowerApps, so much of this is still new to me. 🙂 In any case, here's what I've got:
My app consists of 5 different galleries pointing to a single SharePoint list. This SP list consists of a list of "tasks", and each of those tasks has a "stage" associated with it (1 through 5). Each of my 5 galleries is currently designed to list out the tasks belonging to a specific stage using a simple filter, such as the one below:
Filter(
'Blueprint Use Case Notes',
Stage = 1
)
Each particular task has additional data associated with it via a list column, such as the product line associated with it , the type of security controls being applied as a part of that task, general tags, and so on. FWIW, each of these particular columns are Choice types.
My goal here is to retain the core filtering applied to each gallery so that it only displays the pre-determined stage's tasks, but I also want to be able to add buttons to the app that will allow users to quickly filter the list shown by all 5 galleries based on the other columns I mentioned above (and perhaps others in the future). From what I can gather, there are basically two ways of doing this: filtering using the OnSelect option of the button via UpdateContext(), or filtering via the Items section of the gallery. I've found lots of posts about the latter that seem like they'd almost get me there, but I'm never able to default back to the basic filtering via stage. I recently found posts about the former, but I'm struggling to understand the full logic of it as it pertains to my scenario.
As of late I've been setting a variable on button press and toggling between the two values in order to then reference this value when doing my conditional searching because it seemed like it might be easier to interact with...
If(varPAM = 0,Set(varPAM, 1),Set(varPAM,0))
as opposed to using UpdateContext based on some of the initial posts I came across:
UpdateContext({varPAM: !varPAM})
In either case though, the closest I could get to a working formula for the gallery Items was the following:
If(
varPAM = 1,
Filter(
'Blueprint Use Case Notes',
"PAM" in 'Product Line'.Value && 1 in Stage
),
Filter(
'Blueprint Use Case Notes',
1 in Stage
)
)
However, I'm struggling to understand where I can inject references to the additional buttons without making a giant mess. As I understand it, IF statements within a Filter statement aren't supported (although perhaps they are in a roundabout way, but I'm not able to massage the code I've seen on the subject in a way that works for me). Using an IF statement seems like it would be really handy in this situation, but I imagine there's an easier way to do it.
In case it matters, I have one final restriction that I'll mention. When a user clicks on an item in a given gallery, they're taken to a Detail screen with information about that task. When the user goes back to the gallery screen, I'd like their previous selections to remain and not be cleared. That seems to present somewhat of an issue if I wanted to set variables via the OnVisible section of my BrowseScreen, because when I do that it clears the user's selection, which would force them to reselect those options again. No fun.
Hopefully that's enough context. If not, I'll respond to any questions as soon as I see them. Thanks in advance!