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

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Passing Multiple Value...
Power Apps
Unanswered

Passing Multiple Values from Listbox one at a time to SQL

(0) ShareShare
ReportReport
Posted on by

Hi all,

 

I've got a list box which lists food items such as "Milk", "Cheese" etc (about 20 items)

 

In a SQL table I have 3 columns, the food name, the shop and the price. I want it so that when users pick any number of the food items from the list box, then hit a button it sends each of the selected values through as seperate rows to the SQL table.

 

I've tried just picking out the 'Selected' and it only ever passes through the item which is selected lowest in the list. If I use a 'forall' it will add the number of rows I need, but repeat the same food item for each one as opposed to all of the selected items.

 

I've also tried a flow but no luck - I'm struggling to find the syntax to say "Pass through the selected values each on their own row"

 

Any help?

Categories:
I have the same question (0)
  • BitLord69 Profile Picture
    914 on at
    Re: Passing Multiple Values from Listbox one at a time to SQL

    Have a look at this post: https://powerusers.microsoft.com/t5/PowerApps-Forum/Listbox-MultiSelect-Values/td-p/17709

     

    Can you show your code that dosen't work?

  • Verified answer
    v-micsh-msft Profile Picture
    on at
    Re: Passing Multiple Values from Listbox one at a time to SQL

    Hi @thewake,

     

    Could you please share more information about the source of the ListBox control?

    and Which data do you want to be stored in the SQL Table?

    Further, could you please also share a reference of the forall formula?

    Also, please make sure you have the ListBox MultiSelection (SelectMultiple  property) enabled.

    If you would like to save the selected items in ListBox to the food name column of the SQL table, then the formula of OnSelect property of a Button control should be as below:

    ForAll(ListBox1.SelectedItems.Value,Patch('[dbo].[Foods]',Defaults('[dbo].[Foods]'),{foodName:Value})))

    Note: ‘[dbo].[Foods]’ is a SQL table. The Value in above formula represents the each item of selected items of ListBox control.

     

    Adding some reference:

    ListBox control in PowerApps

    Forall function in PowerApps

     

     

    Regards,

    Michael

  • Community Power Platform Member Profile Picture
    on at
    Re: Passing Multiple Values from Listbox one at a time to SQL

    That worked perfectly. I just didn't have the syntax right. Thanks for the example

  • MK1 Profile Picture
    169 on at
    Re: Passing Multiple Values from Listbox one at a time to SQL

    @v-micsh-msft

     

    LISTBOX DEFAULT SELECT ALL

     

    ComboBox with multi select

    ItemsDistinct(Filter(Product,Name.Id=Dropdown.Selected.ID),Title)

    ListBox

    Items: Distinct(Filter(product,Title in Listbox.SelectedItems),Description)

    Default:LookUp(Product,Title in listbox.SelectedItems.Result,Description)

    textInput: Concat(ADDescription.SelectedItems,Result&",")

     

    while using this scenario, Its working when there is only one item in the combobox and if we select it the description is selected default and added to the textbox

    But, when we select multiple items in the combobox, on description it shows both descriptions are selected but its only populating one description on top of the list.

    Can you help me with were i'm messing with the formula.

    Thanks in advance.

    MK

  • MK1 Profile Picture
    169 on at
    Re: Passing Multiple Values from Listbox one at a time to SQL

    LISTBOX DEFAULT SELECT ALL

     

    ComboBox with multi select

    ItemsDistinct(Filter(Product,Name.Id=Dropdown.Selected.ID),Title)

    ListBox

    Items: Distinct(Filter(product,Title in Listbox.SelectedItems),Description)

    Default:LookUp(Product,Title in listbox.SelectedItems.Result,Description)

    textInput: Concat(ADDescription.SelectedItems,Result&",")

     

    while using this scenario, Its working when there is only one item in the combobox and if we select it the description is selected default and added to the textbox

    But, when we select multiple items in the combobox, on description it shows both descriptions are selected but its only populating one description on top of the list.

    Can you help me with were i'm messing with the formula.

    Thanks in advance.

    MK

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 757 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 322 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 209 Super User 2025 Season 2

Last 30 days Overall leaderboard