web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to convert a strin...
Power Apps
Unanswered

How to convert a string into collection

(0) ShareShare
ReportReport
Posted on by 61

Hello,

 

I am actually trying to convert a string which is stored in a variable into PowerApps collection, the format is like 

[["2017", "Q1","Q2","Q3","Q4"],["2018", "Q1","Q2","Q3","Q4"],["2019", "Q1","Q2","Q3","Q4"],["2020", "Q1","Q2","Q3","Q4"]]

 

trying to achieve using forall and split but not giving me the expected result can you please suggest me to convert this?

 

Thanks in advance!

Categories:
I have the same question (0)
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Sja855 - is this the output you need?

     

    ClearCollect(
     MyNewTable,
     Filter(
     Ungroup(
     ForAll(
     [
     [
     "2017",
     "Q1",
     "Q2",
     "Q3",
     "Q4"
     ],
     [
     "2018",
     "Q1",
     "Q2",
     "Q3",
     "Q4"
     ],
     [
     "2019",
     "Q1",
     "Q2",
     "Q3",
     "Q4"
     ],
     [
     "2020",
     "Q1",
     "Q2",
     "Q3",
     "Q4"
     ]
     ],
     AddColumns(
     ThisRecord,
     "Year",
     First(Value).Value
     )
     ),
     "Value"
     ),
     Value <> Year
     )
    )
  • Sja855 Profile Picture
    61 on at

    @Amik Thanks for your response.

    I forgot to mention that the string is stored in a variable which is returned from Power Automate(Myflowname.run().result) contains the string of data!

    and the table format I am trying to build is 

    Year      Qurter1  Quarter2   Quarter3    Quarter4

    2017         Q1         Q2              Q3               Q4

    2018         Q1         Q2              Q3               Q4

    2019         Q1         Q2              Q3               Q4

     

    Could you please help to achieve this?

     

    Thanks in Advance!

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Sja855 - for that structure you can use:

     

    ClearCollect(
     MyNewTable,
     DropColumns(
     ForAll(
     [
     [
     "2017",
     "Q1",
     "Q2",
     "Q3",
     "Q4"
     ],
     [
     "2018",
     "Q1",
     "Q2",
     "Q3",
     "Q4"
     ],
     [
     "2019",
     "Q1",
     "Q2",
     "Q3",
     "Q4"
     ],
     [
     "2020",
     "Q1",
     "Q2",
     "Q3",
     "Q4"
     ]
     ],
     AddColumns(
     ThisRecord,
     "Year",
     First(Value).Value,
     "Quarter 1",
     Index(
     Value,
     2
     ).Value,
     "Quarter 2",
     Index(
     Value,
     2
     ).Value,
     "Quarter 3",
     Index(
     Value,
     3
     ).Value,
     "Quarter 4",
     Index(
     Value,
     4
     ).Value
     )
     ),
     "Value"
     )
    )

     

  • Sja855 Profile Picture
    61 on at

    Hello @Amik 

     

    I appreciate your help, I am attaching screenshots for your reference. Kindly check and help in correcting this error.

     

    Screenshot 2024-03-18 143431.pngScreenshot 2024-03-18 143534.png

    Thanks in Advance

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Sja855 - the code I gave you will work based on the format/table structure you originally provided.

     

    You're now asking about a different table structure - I can already see that the output of your JSON is different.

     

    Amik_0-1710966772189.png

  • Sja855 Profile Picture
    61 on at

    Hello,

     

    Thanks for your response, the challenge is I need to convert the string which is returned by Power Automate, the challenge lies here, it is not a direct string.

     

    I tried to store the string in a variable and then tried your approach, it was not working.

     

    Then I have used a parse JSON function, then tried the approach to bring it into the table it is giving the following error.

    Sja855_0-1711014211754.png

    How to clear this error, that was my question in previous post sorry If I miss any detail in the previous post!

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Sja855 - you're not understanding my previous response. The solution I provided you was based on the format you provided.

     

    If the format is now something else (which I suspect it is) you will need to provide what that format looks like. In other words, please provide the actual format of the JSON string you're trying to convert, because it certainly looks different to the format you originally posted.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard