cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
fbarini
Helper I
Helper I

Multiples IFs to Filter Gallery

Hello Folks, hope someone can give me a light on this since I'm struggling to find the answer for the past few days...

 

I can't find a solution to filter my gallery. I need to fulfill two condition, but I always end up comparing a TEXT to a TABLE. Is there anyway to use the IF formula to compare my logical statement row by row? I need to Filter my gallery accordingly to the Approver, so If someone makes a New Request, Approver 1 would see it, but Approver 2 not. Once Approver 1 approved, he wouldn't be able to reach out the record anymore and Approver 2 would be able to see it.

 

The following formula Filter(BaseAppRH;And('Status Aprov. 1' = "Analysing"; User().Email = 'Aprov 1.') worked for what I'm trying to achieve, but I need to insert a IF before it, in case Approver 2 is online, which would translate to the following Filter(BaseAppRH;And('Status Aprov. 2' = "Analysing"; User().Email = 'Aprov 2.') 

 

In the end of the day, I need something like If(User().Email = Approver 1; First Aforementioned Example; Second Aforementioned Example), but as of now, the only way I've found to achieve this is swapping the column Approver 1 to "MyEmail@PowerApps.com", which is not ideal because if I need to change the approvers, I'd need to change the formula and not the table it refers to.

 

Thanks in advance to anyone!

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@fbarini 

Avoid using If's in your formulas with filters.

Please consider changing your Formula to the following:

Filter(BaseAppRH; 
   ('Status Aprov. 1' = "Analysing" && StartsWith('Aprov 1.'; User().Email)) ||
   ('Status Aprov. 2' = "Analysing" && StartsWith('Aprov 2.'; User().Email)) 
)

 

I'm not completely clear on your logic that you are trying to achieve, but the above is what I am getting from your logic.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@fbarini 

Avoid using If's in your formulas with filters.

Please consider changing your Formula to the following:

Filter(BaseAppRH; 
   ('Status Aprov. 1' = "Analysing" && StartsWith('Aprov 1.'; User().Email)) ||
   ('Status Aprov. 2' = "Analysing" && StartsWith('Aprov 2.'; User().Email)) 
)

 

I'm not completely clear on your logic that you are trying to achieve, but the above is what I am getting from your logic.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Sadly it didn't work. I couldn't return any records, even when using only one line (don't even know why, since it seems to be correct).

 

What I really want is that each user only sees the approvals that are under them, in other words, if Approver 1 already Approved ID 1, he won't be able to reach out the record  anymore and it would only be visible to Approver 2.

 

When using Filter(BaseAppRH;'Status Aprov. 1' = "Em Análise" && User().Email = 'Aprov 1.') I get 2 records. 

I tried using your Filter(BaseAppRH;('Status Aprov. 1' = "Analysing" && StartsWith('Aprov 1.'; User().Email))) but it brought 0 records... Below my sharepoint table.

 

Also, when using 'Aprov. 1' = User().Email on a Text INput, I get true. Which makes very confusing as of why it isn't working

papps.png

Filter(BaseAppRH; 
   ('Status Aprov. 1' = "Analysing" && 'Aprov 1.' = User().Email) ||
   ('Status Aprov. 2' = "Analysing" && 'Aprov 2.' = User().Email) 
)

I swapped the StartWith for " = " and it worked! Thanks!

RandyHayes
Super User
Super User

@fbarini 

That will work, just be cautious with using the equal "=" on emails...many times the letter case is different - someone@company.com is the same email as Someone@company.com but the equal operator will NOT see them as equal because of the letter case.  The StartsWith is the trick to avoid that issue because it is not case sensitive.

 

  "someone@company.com"  = "Someone@company.com"  is false

  StartsWith("someone@company.com", "Someone@company.com") is true

 

Glad you have it working now.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (4,959)