cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JoeColvile
Frequent Visitor

Record alternate result for multi select for SQL

Hi all,

My title is not the most concise but what I am doing is building an app which acts as a front end for an SQL script executed in power automate. I have got most of it working however I am having an issue with multi-select fields. I have two of them, the example I will give is a vendor filter. As the user might want to filter on multiple vendors and not just single selection they can select multiple. These selections are sourced from a database table. 

 

What I want is:

- User selects all the vendors they want (e.g. ven1, ven2, ven3) then when they click run I want that to input to the SQL query in power automate as ('ven1'),('ven2'),('ven3') so that it can be processed.

 

JoeColvile_0-1622785337165.png

 

 

Does any one have any insight into how I can do this?

 

Thanks in advance,

 

Joe

1 ACCEPTED SOLUTION

Accepted Solutions
v-albai-msft
Community Support
Community Support

Hi @JoeColvile ,

From your description, I assume that you want to get a result format like ('ven1'),('ven2'),('ven3')

If yes, you can try this solution. I will explain why I use this solution in below.

1. When I select 4 selectins in my combo box, the result shows as a table:

v-albai-msft_0-1622799018190.png

v-albai-msft_2-1622799207595.png

 

2. I can use Concatenate function to change its format:

ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')"))

v-albai-msft_3-1622799297420.png

 

3. Then I can use Concat function to convert above result into a string:

Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&",")

v-albai-msft_4-1622799414297.png

 

4. Format above result to remove last ","  (based on your actual situation, maybe you need to change the last number to "-2"):

Left( Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&","), 
Len( Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&",") ) - 1 )

v-albai-msft_5-1622799535364.png

 

This time we already get the result, we can also save the result into variable so that we can directly use this variable in other formula. Set OnChange property of your combo box to below:

Set(varVendor,
Left( Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&","), 
Len( Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&",") ) - 1 ))

v-albai-msft_6-1622799642306.png

Best regards,

Allen

View solution in original post

3 REPLIES 3
Aki78
Helper I
Helper I

You could put a button next to your vendors dropdown that adds the dropdown.selected.value in to a context variable array- this way you can add as many vendors from the dropdown as you like...  and then call the context variable in to your 'run function'.

v-albai-msft
Community Support
Community Support

Hi @JoeColvile ,

From your description, I assume that you want to get a result format like ('ven1'),('ven2'),('ven3')

If yes, you can try this solution. I will explain why I use this solution in below.

1. When I select 4 selectins in my combo box, the result shows as a table:

v-albai-msft_0-1622799018190.png

v-albai-msft_2-1622799207595.png

 

2. I can use Concatenate function to change its format:

ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')"))

v-albai-msft_3-1622799297420.png

 

3. Then I can use Concat function to convert above result into a string:

Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&",")

v-albai-msft_4-1622799414297.png

 

4. Format above result to remove last ","  (based on your actual situation, maybe you need to change the last number to "-2"):

Left( Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&","), 
Len( Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&",") ) - 1 )

v-albai-msft_5-1622799535364.png

 

This time we already get the result, we can also save the result into variable so that we can directly use this variable in other formula. Set OnChange property of your combo box to below:

Set(varVendor,
Left( Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&","), 
Len( Concat(ForAll(ComboBox6.SelectedItems,Concatenate("('",Value,"')")),Value&",") ) - 1 ))

v-albai-msft_6-1622799642306.png

Best regards,

Allen

Hi,

 

This solution looks like it would work very well. I will let you know how I go.

 

Thanks,

 

J

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,283)