cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chris2
Regular Visitor

Nested IF statements to filter a data table

Hey all,

 

I am currently working on filtering a data table via two parameters. Anayst (I misspelled Analyst in source file) and Stock symbol. Anayst is populated via Dropdown2 and Stock Symbol is populated via ComboBox1.

The filter currently works if I have both an Analyst and a Stock symbol selected but not if only one or the other is selected.

 

My goal is to be able to filter by Analyst or stock symbol independently but also be able to filter by the combination of both (ie Analyst and stock symbol)

 

Below is the equation I'm using. 

If(IsBlank(Dropdown2.SelectedText.Result), Filter(Table1, 'Stock Symbol'= ComboBox1.Selected.'Stock Symbol'), If(IsEmpty(ComboBox1), Filter(Table1, Anayst= Dropdown2.SelectedText.Result), Filter(Table1, 'Stock Symbol'= ComboBox1.Selected.'Stock Symbol' && Anayst= Dropdown2.SelectedText.Result)))

 

Any help would be greatly appreciated. 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Chris2 ,

Do you want to filter your Data Table records based on any combination of the two filter conditions?

 

Based on the formula that you mentioned, I think it is complex. I have made a test on my side, please try the following formula (set the Items property of Data Table to following😞

Filter(
       Table1,
       If(
          IsBlank(Dropdown2.SelectedText.Result),
          true,
          Anayst= Dropdown2.SelectedText.Result
       ),
       If(
           IsBlank(ComboBox1.Selected.'Stock Symbol'),
           true,
           'Stock Symbol'= ComboBox1.Selected.'Stock Symbol' 
       )
)

Please take a try with above solution, hopes it could solve your problem.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @Chris2 ,

Try the below - I also have allowed for all records to be displayed if both  controls are blank

Filter(
   Table1, 
   If(
      IsBlank(Dropdown2.SelectedText.Result) && IsEmpty(ComboBox1),
      true,
      IsBlank(Dropdown2.SelectedText.Result), 
      'Stock Symbol'= ComboBox1.Selected.'Stock Symbol',
      IsEmpty(ComboBox1), 
      Anayst= Dropdown2.SelectedText.Result,
      'Stock Symbol'= ComboBox1.Selected.'Stock Symbol' && 
      Anayst= Dropdown2.SelectedText.Result
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

v-xida-msft
Community Support
Community Support

Hi @Chris2 ,

Do you want to filter your Data Table records based on any combination of the two filter conditions?

 

Based on the formula that you mentioned, I think it is complex. I have made a test on my side, please try the following formula (set the Items property of Data Table to following😞

Filter(
       Table1,
       If(
          IsBlank(Dropdown2.SelectedText.Result),
          true,
          Anayst= Dropdown2.SelectedText.Result
       ),
       If(
           IsBlank(ComboBox1.Selected.'Stock Symbol'),
           true,
           'Stock Symbol'= ComboBox1.Selected.'Stock Symbol' 
       )
)

Please take a try with above solution, hopes it could solve your problem.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This was beneficial and better than mine. It worked correctly if both were selected or if just the combo box was selected. It did not allow me to filter on just the Anayst field however. 

 

Thank you!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,006)