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

View solution in original post

Hi,

 

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

 

Thanks,

 

J

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

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

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