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

Returning an array to a power app collection - How to including decimal numbers

Good day. I have used this very helpful guide to return the results from an SQL query to a collection in a power app.

https://powerapps.microsoft.com/nl-nl/blog/return-an-array-from-a-sql-stored-procedure-to-powerapps-...

 

The only issue that I have is that it does not seem to recognise decimal numbers e.g. 0.2 or 1235.89.

 

Here is the full AddCoIums statement that is being used to covert the text to the collection.

 

"tableFields",
AddColumns(
// Match key value pairs in this pattern {"Column_name":"Value"}.
MatchAll(
ThisRow.Result,
""".+?""\:(\[.+?\]|\{.+?\}|"".+?""|\d{1,}|true|false|null)(?=\,|\})"
).FullMatch As ThisField,

// Get the column name between quotation marks.
"Key",Match(ThisField.FullMatch,"(?<="").+?(?=""\:)").FullMatch,

"Value",
With(
{
TextMatch:
With(
{
// Get the position of the colon to help find hte text.
StartMatch: Find(":",ThisField.FullMatch)
},
// Get the text after the colon.
Mid(ThisField.FullMatch,StartMatch+1,Len(ThisField.FullMatch)-StartMatch)
)
},
If(
// Check if the match is a string wrapped in quotes.
And(
Left(TextMatch,1)=Char(34),
Right(TextMatch,1)=Char(34)
),
// Remove the quotes around strings.
Replace(Replace(TextMatch,1,1,""),Len(TextMatch)-1,1,""),

TextMatch="null",Blank(),

TextMatch
)
)
)

 

1 ACCEPTED SOLUTION

Accepted Solutions
Garethterb
Frequent Visitor

I have managed to solve this by adding  this \d+\.?\d into the regex expression as follows:

""".+?""\:(\[.+?\]|\{.+?\}|"".+?""|\d{1,}|\d+\.?\d+|true|false|null)(?=\,|\})"

View solution in original post

1 REPLY 1
Garethterb
Frequent Visitor

I have managed to solve this by adding  this \d+\.?\d into the regex expression as follows:

""".+?""\:(\[.+?\]|\{.+?\}|"".+?""|\d{1,}|\d+\.?\d+|true|false|null)(?=\,|\})"

View solution in original post

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (43,814)