web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Duplicate items fetche...
Power Apps
Unanswered

Duplicate items fetched in listbox from multi selecteditems in another listbox

(0) ShareShare
ReportReport
Posted on by 10

I have below assets on my powerapp.

2 data sources:(Excel tables)

 -> DevItems

Siddiq53_1-1716461979497.png

 -> QAItems

Siddiq53_2-1716461994385.png

 

two dropdowns 

 -> dropdown1 -- Environment selector-- User can select from items - ["Dev", "QA"]

 -> dropdown2-- Access selector-- User can select from items - ["Reader", "Contributor"]

Siddiq53_0-1716461907806.png

two list boxes:

 -> listbox1 -- When user selects environment from dropdown1, it should display the items present under "resource" column of that particular data source table.

 -> listbox2 -- Now user will select Access Type from dropdown2. It will be either "Reader" or "Contributor". Then user selects single or multiple items from listbox1. Now listbox2 should show the corresponding items present under specific column of same data source that matches the access type.

For example:

  • When user selects Dev from dropdown1, it should list all the items present under resource column of DevItems table in the listbox1.
  • Now user will select the access type as Reader from dropdown2.
  • Then he will select two items from listbox1. dev-webapp and dev-sql.
  • Now the listbox2 should show, dev-app-reader and dev-sql-reader.

 

Currently I am using below code.

  • dropdown1 --  Items = ["Dev","QA"]
  • dropdown2 --  Items = ["Reader", "Contributor"]
  • listbox1 ------- Items = If(Dropdown1.Selected.Value = "Dev", DevItems.resource, QAItems.resource)
  • listbox2 ------- Items = 

    // Clear the collection at the beginning
    Clear(colItems);

    // Loop through each selected item in ListBox1 and collect the corresponding items into the collection
    ForAll(
    ListBox1.SelectedItems,
    Collect(
    colItems,
    If(
    Dropdown1.Selected.Value = "Dev",
    If(
    Dropdown2.Selected.Value = "Reader",
    LookUp(DevItems, resource in ListBox1.SelectedItems).reader,
    Dropdown2.Selected.Value = "Contributor",
    LookUp(DevItems, resource in ListBox1.SelectedItems).contributor
    ),
    Dropdown1.Selected.Value = "QA",
    If(
    Dropdown2.Selected.Value = "Reader",
    LookUp(QAItems, resource in ListBox1.SelectedItems).reader,
    Dropdown2.Selected.Value = "Contributor",
    LookUp(QAItems, resource in ListBox1.SelectedItems).contributor
    )
    )
    )
    )

ISSUE:

Currently listbox2 is displaying duplicate items based on selected items from listbox1.

from the above given example, instead of displaying dev-app-reader and dev-sql-reader, it is displaying dev-app-reader twice.

Screenshot for reference. Need help in fixing this.

Siddiq53_3-1716462985273.png

NOTE: This works fine when I select single item from listbox1. Issue is upon selecting multiple items.

Categories:
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Siddiq53 ,

     

    Please try below method:

    OnVisible of the screen:

    ClearCollect(colAll, DevItems, QAItems)

    dropdown1 --  Items = ["Dev","QA"]

    dropdown2 --  Items = ["Reader", "Contributor"]

    listbox1 ------- Items = 

    Filter(colAll, StartsWith(resource, Dropdown1.Selected.Value))

    listbox2 ------- Items = 

    Switch(
     Dropdown2.Selected.Value, 
     "Reader", 
     ForAll(
     ListBox1.SelectedItems, {Value: ThisRecord.reader}
     ), 
     "Contributor", 
     ForAll(
     ListBox1.SelectedItems, {Value: ThisRecord.contributor}
     )
    )

     

    Best regards,

  • Siddiq53 Profile Picture
    10 on at

    @v-jefferni ,
    Thank you for the solution. It worked perfectly untill I added a new column in my source tables.

    Siddiq53_0-1716551083687.png

     

    My agenda is to allow user to select Environment from dropdown1, and access type from dropdown2 then user clicks on fetch resources button.

    • This should now fetch all the ResourceTypes (Distinct values) in listbox1.
    • Then user select any particular Resource Type from listbox1. (it could be single item or multiple)
    • Now it should fetch all the resources into listbox2, based on listbox1 selection. It should fetch all the resource items that match the ResourceType from listbox1.
    • Then when user selects list of resources from listbox2, it should fetch the corresponding items based on  "Access Type" selection in dropdown2. (reader items for Reader and contributor items for Contributor)

    My app typically looks this way.

    Siddiq53_2-1716545923911.png

    NOTE: This is for testing I am using only two environments. Actually there are more than two environments. So I need a solution to be built that can support multiple environments which in turn are multiple source tables.

     

    Also the resource names are just for testing. Actual names will vary and may not start with "Dev" or "QA" words. 

    can you please help with this??

     

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @Siddiq53 ,

     

    My solution is very specific to your original question/scenario. I think you'd better open a new case and share the actual backgrounds, so that we'll be able to find a solution for you.

     

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 350 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 318

#3
Mohsin Ali Profile Picture

Mohsin Ali 220

Last 30 days Overall leaderboard