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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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