cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
aec2018
Microsoft
Microsoft

Can I turn table values into an array of strings?

I have a gallery table with checkboxes used to collect id's. The id's will then be put into a query to call our API. The empty collection is initiated on page load with: 

 

ClearCollect(selectedIds, []);

 

The OnSelect for the checkbox is:

 

Collect(selectedIds, ThisItem.Id);

 

I get a table with :

 

Value

123
456

 

I then have to create a query string like so:

 

CustomConnectorCall.getData(query:"query{GetData(where:{ids:{eq: ["123", "456"]}}){...}}")

 

I know I'll have to do some form of string concatenation but how can I parse through a collection of unknown quantities to add to this string? In code, I would just write a for loop but I'm not sure how to do that in PowerApps. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
JasonWS
Resolver II
Resolver II

The Concat() function is exactly what you are looking for. This should work:

 

 

 

 

Concat(selectedIds, Value & ",")

 

 

 

EDIT: The only issue is there will be a trailing comma at the end. And I now see you custom string you need is a little more complex. Perhaps something like the below.

 

 

 

Concat(selectedIds,Char(34) & Value & Char(34) & ", ")

 

 

 

Take a look here for the Microsoft article about Concat() and Concatenate(): Concat and Concatenate functions in Power Apps - Power Platform | Microsoft Learn

View solution in original post

2 REPLIES 2
JasonWS
Resolver II
Resolver II

The Concat() function is exactly what you are looking for. This should work:

 

 

 

 

Concat(selectedIds, Value & ",")

 

 

 

EDIT: The only issue is there will be a trailing comma at the end. And I now see you custom string you need is a little more complex. Perhaps something like the below.

 

 

 

Concat(selectedIds,Char(34) & Value & Char(34) & ", ")

 

 

 

Take a look here for the Microsoft article about Concat() and Concatenate(): Concat and Concatenate functions in Power Apps - Power Platform | Microsoft Learn

aec2018
Microsoft
Microsoft

@JasonWS Yup! That worked for me. I was able to add the quotes around each item after reading the docs. I wasn't aware concat would smash a table like that but it works perfectly. Thanks!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,858)