Hey friends! I'm trying to build a simple search of a gallery that's filtered by two toggles:
The goal would be something like this:
If(
And(EXPIRATIONFILTER.Value = false,INACTIVEFILTER.Value = true), SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending),
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = true),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = false), Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
And(EXPIRATIONFILTER.Value = false,INACTIVEFILTER.Value = false), Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending)
)
But I'm getting an error here:
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = false), Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
I feel like there's a logical fail I'm not seeing. Re-ordering the statements doesn't help.
But this works:
If(
And(EXPIRATIONFILTER.Value = false,INACTIVEFILTER.Value = true), SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending),
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = true),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = false), SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
And(EXPIRATIONFILTER.Value = false,INACTIVEFILTER.Value = false), Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending)
)
So adding Filter to the third statement is where things are breaking.
For the heck of it, I've also written two working Switch statements, but I can't get them to work together:
Switch(EXPIRATIONFILTER.Value, true, SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending), false, SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending))
Switch(INACTIVEFILTER.Value, false, Search(Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SEARCHPARTNERS.Text,"Title"), true, Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"))
Any help would be GREATLY appreciated!
Solved! Go to Solution.
Hi @ianhilltegna :
Firstly, let me explain why you encounter the error.
The key is formula syntax error.
The result of this code is two tables ,but a gallery can only have one data source.
Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending)
The correct way is to combine these two functions:
SortByColumns(Search(Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending)
Secondly,the reason that the correctly allowed code can run is that the second table is defaulted as the result of the four conditions are not met.
Four conditions are not satisfied:
SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending)
Finally, I suggest you try this code:
If(
And(EXPIRATIONFILTER.Value = false,INACTIVEFILTER.Value = true), SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending),
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = true),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = false),SortByColumns(Search(Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
And(EXPIRATIONFILTER.Value = false,INACTIVEFILTER.Value = false),SortByColumns(Search(Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending)
)
In addition,I think this link will help you a lot:
If and Switch functions in Power Apps
Best Regards,
Bof
Hi @ianhilltegna :
Firstly, let me explain why you encounter the error.
The key is formula syntax error.
The result of this code is two tables ,but a gallery can only have one data source.
Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending)
The correct way is to combine these two functions:
SortByColumns(Search(Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending)
Secondly,the reason that the correctly allowed code can run is that the second table is defaulted as the result of the four conditions are not met.
Four conditions are not satisfied:
SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending)
Finally, I suggest you try this code:
If(
And(EXPIRATIONFILTER.Value = false,INACTIVEFILTER.Value = true), SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending),
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = true),SortByColumns(Search('CONTENT PARTNERS',SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
And(EXPIRATIONFILTER.Value = true,INACTIVEFILTER.Value = false),SortByColumns(Search(Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SEARCHPARTNERS.Text,"Title"),"EXPIRES",Descending),
And(EXPIRATIONFILTER.Value = false,INACTIVEFILTER.Value = false),SortByColumns(Search(Filter('CONTENT PARTNERS',!("Inactive" in 'ACTIVE ONBOARDING INACTIVE')),SEARCHPARTNERS.Text,"Title"),"WHENUPDATED",Descending)
)
In addition,I think this link will help you a lot:
If and Switch functions in Power Apps
Best Regards,
Bof
That solved it! Thank you!
User | Count |
---|---|
196 | |
124 | |
87 | |
49 | |
42 |
User | Count |
---|---|
284 | |
163 | |
138 | |
75 | |
72 |