cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Yuna-Evita
Helper I
Helper I

Filter on selected column from listbox

Hello,

 

I have a microsoft list link to my power apps, I have columns for cities and incidents in line, these columns are choice column "Yes", "No" or "In progress".

 

In my apps I have my gallery, listbox1 with cities name in and dropdown1 State for "All", "Yes", "No" and "In progress".

 

I need to filter my gallery with the cities selected and the State selected.

I can filter for one city, Valencia here, and I don't know how to do it with the city selected in listbox1

 

If(

Dropdown1.SelectedText.Value="All",
(SortByColumns(Filter([@TestEmilien], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))),

 

(SortByColumns(Filter([@TestEmilien], Valencia.Value=Dropdown1.SelectedText.Value), "Title", If(SortDescending1, Descending, Ascending)))

)

 

I tried with Search:

If(

Dropdown1.SelectedText.Value="All", (SortByColumns(Filter([@TestEmilien], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))),

 

(SortByColumns(Search(TestEmilien, dropdown1.SelectedText.Value, ListBox1.Selected.Value), "Title", If(SortDescending1, Descending, Ascending))))

 

but I have an error : The function "Search" has some invalid arguments

1 ACCEPTED SOLUTION

Accepted Solutions

@Yuna-Evita If you don't want to change the design, fine. Then you have to check all the field one-by-one.

If(

Dropdown1.SelectedText.Value="All",
(SortByColumns(Filter([@TestEmilien], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))),

 

(SortByColumns(Filter([@TestEmilien], (Valencia.Value=Dropdown1.SelectedText.Value || Auckland.Value=Dropdown1.SelectedText.Value || keep adding other fields... ), "Title", If(SortDescending1, Descending, Ascending)))

)

 

View solution in original post

8 REPLIES 8
CNT
Super User
Super User

@Yuna-Evita You should have only one column for the cities and not one column for each city. You can call it City and store the name of the city there. Then your formula will be,

If(

Dropdown1.SelectedText.Value="All",
(SortByColumns(Filter([@TestEmilien], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))),

 

(SortByColumns(Filter([@TestEmilien], City.Value=Dropdown1.SelectedText), "Title", If(SortDescending1, Descending, Ascending)))

)

Yes but I don't need to store the city's name, I need to store the state for each cities for each incidents 

@Yuna-Evita Sorry not very clear. Can you share a screen shot of the List settings with the Column names.

Yuna-Evita
Helper I
Helper I

YunaEvita_0-1637675019452.png

 

Yuna-Evita
Helper I
Helper I

In my list, I stock incident, and I have a lot of column for a lot of cities, the choice column with city's name can contain "Yes", "No" or "In progress" that what I called the state

 

 

@Yuna-Evita This is very bad design. Sorry!

If you have one column for each city, if you want to add more citis later, you have to change the SP List and your PowerApps. It will become unmanageable. Moreover, you don't have to do it this way.

Just have ONE choice column called City and then a choice coulmn called CitySate to know which state that city is in ("Yes", "No" or "In progress") and then another column CityDescription for the description. 

Yuna-Evita
Helper I
Helper I

I know for the design no probleme, 

But I'm not sure to understand what do you mean by then 

 

@Yuna-Evita If you don't want to change the design, fine. Then you have to check all the field one-by-one.

If(

Dropdown1.SelectedText.Value="All",
(SortByColumns(Filter([@TestEmilien], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))),

 

(SortByColumns(Filter([@TestEmilien], (Valencia.Value=Dropdown1.SelectedText.Value || Auckland.Value=Dropdown1.SelectedText.Value || keep adding other fields... ), "Title", If(SortDescending1, Descending, Ascending)))

)

 

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,237)