I'm really struggling with power apps language because other languages that use semi-colons tell the language processor it's an end of line. Unfortunately what I'm discovering with power apps is that the comma (,) becomes the delimiter in IF (and switch) statements that really make it hard to do something like this. Here is my objective:
I have a pulldown menu that I was able to create a collection of my values (from SPList) and add another value to the top called "All". This way the top of the pulldown has "All" first, and then all the distinct values from my SPList column. Let's call that pulldown list 'PulldownList' for now. I also have a searchbox that is called "SearchInput.Text" that will filter the final results. The last step is to sortbycolumns. Here is what I'd like to do:
If(PulldownList.Selected.Result = "All",
SortByColumns(
Filter(
Filter(
colResults
),
SearchInput.Text in Title
),
ascending
)
, // (This comma is the ELSE for the If Statement)
SortByColumns(
Filter(
Filter(
colResults,
'Person'.DisplayName = 'PulldownList'.DisplayName
),
SearchInput.Text in Title
),
ascending
)
) //This closes the IF statement
So basically, if the selection in the dropdown is "All", then perform the code in orange. If it's not all, sort by the person's name (or selected result form the pulldown) and execute the blue code.
Now you might be asking me, well, why don't you just put an if statement inside the second filter instead of using the whole filter command twice - well this is where I'm still stuck because there's a comma required in the if statement that I haven't figured out how to tell IF to not look at and bypass it. So for instance:
So take a standard sortbycolumns filter I'm using like this and attempt to inject an if statement right where it counts:
SortByColumns(
Filter(
Filter(
colResults,
If(PulldownList.Selected.Result <> "All", 'Person'.DisplayName = 'PulldownList'.DisplayName)
),
SearchInput.Text in Title
),
ascending
)
the problem I face is the comma after the colResults. In Filter, you have to pass a comma after the data source to indicate there is a condition to be met. Well, in this case, if the pulldown menu selection is "All", I just want it to be:
Filter(colResults)
and not
filter(colResults,) //Note the comma after colResults
but I can't pass a comma in the IF statement, because the comma tells IF that it's part of the condition for IF. So my question to all you power apps users, is how do you pass a full filter statement, complete with commas, in an if condition? I've tried this with switch also, but it doesn't work. I'm sure there's someone out there who has done this, but I'm so accustomed to other languages that use semicolons to end lines, that commas aren't an issue.
Anyone come across this before?
Thanks in advance!