cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kmk
Helper V
Helper V

How to filter items from selected multiple ListBox values.

Hi Mates,

we have requirement to apply filter with multiple values... example : from listbox select multiple item next listbox load and display values respective rows.

multipel selection2.png

When selected(clicked) on Car Then filter and display in listbox2 with LA,Calif,SW, if selected/clicked car and Bus then has to load LA,Calif,SW,TR,TS but its not loading..

let say click/selected on Bus,bike then MM,TR,TS

As of now i have two list boxes(list box 1, list box 2)

list box 1 Property : Item: Distinct(Test,Travel)

list box 2 property : Item: Sort(Distinct(Filter(Test,Travel=list box 1.Selected Text. Value),Route),Result,Ascending)

here issue is i can not get values when selected multiple values, but i can get only for one item at a time 

means as per table above 

 

Also share your idea using list box is right way or if we have any simple/better way to filter by selecting multiple items.

Help would be highly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @kmk :

Do you want to implement the following functions:

  • When a user selected select multiple selecions in list1, list2 will display all relevant options.

Firstly , let me explain why you can only get the result of the first option.

The key is that "list box 1.SelectedText" only quotes the value of first record.In addition, "list box 1.Selected" is the same, only quoting the first record.

Secondly,I suggest you try "Travel in ListBox1.SelectedItems.Result".

The key is to get all the records.

I've made a test for your reference:

My data source:

 

ClearCollect(
    Test,
    {
        Travel: "Car",
        Route: "LA"
    },
    {
        Travel: "Car",
        Route: "Calif"
    },
    {
        Travel: "Car",
        Route: "SW"
    },
    {
        Travel: "Bus",
        Route: "TR"
    },
    {
        Travel: "Bus",
        Route: "TS"
    },
    {
        Travel: "Bus",
        Route: "MM"
    }
)

 

Add two list boxes(ListBox1,ListBox2)

ListBox1-Items:

 

Distinct(Test,Travel)

 

ListBox2-Items:

 

Sort(Distinct(Filter(Test,Travel in ListBox1.SelectedItems.Result),Route),Result,Ascending)

 

 1.jpg

Best Regards,

Bof

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @kmk :

Do you want to implement the following functions:

  • When a user selected select multiple selecions in list1, list2 will display all relevant options.

Firstly , let me explain why you can only get the result of the first option.

The key is that "list box 1.SelectedText" only quotes the value of first record.In addition, "list box 1.Selected" is the same, only quoting the first record.

Secondly,I suggest you try "Travel in ListBox1.SelectedItems.Result".

The key is to get all the records.

I've made a test for your reference:

My data source:

 

ClearCollect(
    Test,
    {
        Travel: "Car",
        Route: "LA"
    },
    {
        Travel: "Car",
        Route: "Calif"
    },
    {
        Travel: "Car",
        Route: "SW"
    },
    {
        Travel: "Bus",
        Route: "TR"
    },
    {
        Travel: "Bus",
        Route: "TS"
    },
    {
        Travel: "Bus",
        Route: "MM"
    }
)

 

Add two list boxes(ListBox1,ListBox2)

ListBox1-Items:

 

Distinct(Test,Travel)

 

ListBox2-Items:

 

Sort(Distinct(Filter(Test,Travel in ListBox1.SelectedItems.Result),Route),Result,Ascending)

 

 1.jpg

Best Regards,

Bof

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,465)