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 / Issues spliting result...
Power Apps
Answered

Issues spliting result from Power Automate in Power Apps from query to Azure Dev Ops

(0) ShareShare
ReportReport
Posted on by 1,512

I have the flow running correctly in Power Automate, I am referencing this code from a LinkedIn learning.

 

However I am having issues with this section of code and am stuck

 

ClearCollect(GetMyTasks,
AddColumns(Split(JsonOutput,Char(13),
"Title, Mid(Result,Find("A/",Result)+4+1,Find("B/",Result)-(Find("A/",Result)+4+2+2)))));

 

Getting errors everywhere, doesnt like Result,  I cant figure out how to break it apart in Power Automate so I do not have to do all this mess in Power Apps.

 

Any help would be appreciated.

Categories:
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Dorinda,

     

    Recently the output of Split() and Distinct() has changed from Result to Value. Some brackets were also a bit out of place, which I altered in the code below.

     

     

    ClearCollect(
     GetMyTasks,
     AddColumns(
     Split(
     JsonOutput,
     Char(13) // (The post mentioned "\n")
     ),
     "Title", 
     Mid(Value, Find("A/",Value)+4+1,Find("B/",Value)-(Find("A/",Value)+4+2+2))
     )
    );

     

     

    I hope this helps! 😊

     

    Edit: actually forgot to change Result to Value in my code snippet, has been corrected now 😛

  • Dorinda Profile Picture
    1,512 on at

    @LaurensM I reran the on select and it is working, however, I think i left off a few of the fields from the flow 

    Dorinda_0-1681764440594.png

     

     

    not sure how to add those into the code you provided.

  • Dorinda Profile Picture
    1,512 on at

    @LaurensM so this is the code, I think it is a mess

    ClearCollect(
     GetMyTasks,
     AddColumns(
     Split(
     JsonOutput,
     Char(13)
     ),
     "AValue", Substitute(Substitute(Substitute(Mid(Value, 0, Find("A/",Value)), """", ""), ",", ""), ":", ""),
     "Title", Substitute(Substitute(Substitute(Mid(Value, Find("A/",Value)+2,Find("B/",Value)-(Find("A/",Value)+2)), """", ""), ",", ""), ":", ""),
     "BValue", Substitute(Substitute(Substitute(Mid(Value, Find("B/",Value)+2,Find("C/",Value)-(Find("B/",Value)+2)), """", ""), ",", ""), ":", ""),
     "CValue", Substitute(Substitute(Substitute(Mid(Value, Find("C/",Value)+2,Find("D/",Value)-(Find("C/",Value)+2)), """", ""), ",", ""), ":", ""),
     "DValue", Substitute(Substitute(Substitute(Substitute(Mid(Value, Find("D/",Value)+2,Find("A/",Value, Find("D/",Value)+2)-(Find("D/",Value)+8)), """", ""), ",", ""), ":", ""), "\n", "")
     )
    );

    still have a bunch of characters that shouldn't be showing and only one record was returned I am showing a lot more in my flow. 

     

    Any idea what is causing this?

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Dorinda,

     

    To preface, the guide is quite old and recently you don't have to manually parse json via these text functions. You could remove the Join action from your flow and provide viable column names in your Select (Title instead of A/ and so on). Use the Output from the Select as your response, not the Join. To fetch it to a collection leverage the recent ParseJSON() function:

     

    Clear(GetMyTasks);
    ForAll(
     Table(ParseJSON(JsonOutput)),
     Collect(
     GetMyTasks,
     {
     //I replaced my A/ and B/ column names in the Select action with Title and Item, adjust or add where necessary
     Title: Text(ThisRecord.Value.Title),
     Item: Text(ThisRecord.Value.Item)
     }
     )
    )

    Reza Dorrani has a very good guide on this function.

     

    That being said, below you will find the way proposed in the LinkedIn Learning post.

    I did some testing on my end (with a test JSON that mimics the post output) and the following solution worked (integrated it into your code):

    ClearCollect(
     GetMyTasks,
     AddColumns(
     Split(
     JsonOutput,
     "\n"
     ),
     "Title", 
     Mid(Value, Find("A/",Value)+5,Find("B/",Value)-(Find("A/",Value)+8)),
     "AssignedTo", 
     Mid(Value, Find("B/",Value)+5,Find("C/",Value)-(Find("B/",Value)+8)),
     "State", 
     Mid(Value, Find("C/",Value)+5,Find("D/",Value)-(Find("C/",Value)+8)),
     "ID", 
     Mid(Value, Find("D/",Value)+5,Find("}",Value)-(Find("D/",Value)+6)) //careful, here it is +6 not +8
     )
    );

     

    The single record issue was caused because you are currently splitting on Char(13) but the linebreak is hardcoded as a \n string. In other words the split separator should be "\n".

     

    The post did not go into detail why it was using +4 +1 and +4 +2 +2, so I will explain this briefly as well. This way the code and random numbers will make a lot more sense 🙂

     

    The Mid() function expects 3 parameters - with the 3rd being optional: Mid(string, startingPosition, {NumberOfChars}). This function allows you to extract text from other text values starting from a certain position or between 2 positions, the latter is used in the code above.

     

    If we take a look at the value that is received by the Power App, it looks as follows (my test JSON):

    {"A/":"title1","B/":"item1"}"\n"{"A/":"title2","B/":"item2"}

     

    Split(JsonOutput, "\n") will result in a table split by the \n separator:

    {"A/":"title1","B/":"item1"}"
    "{"A/":"title2","B/":"item2"}

     

    Should we want the Title we will have to extract the title value via the Mid() function. To get the starting position we will use Find("A/",Value) which gives us the starting position of A/ {"A/":"title1"... However we don't want to use that as our starting point, want to skip the following characters: {"A/":"title1"... -> this gives us the 4+1, or simply +5

     

    We will also have to define our stopping point, which is Find("B/",Value)-(Find("A/",Value)+8)

    Here we take the index of the B character minus our index of A + 8 to get rid of the other characters:

    {"A/":"title1","B/":"item1"}"

    This leaves us with the actual A/ value (or title). Note: the last item (D/ is a bit different)

     

    As you can probably tell, the new ParseJSON function makes our lives a lot easier so I would highly recommend trying that approach.

     

    I hope this helps!

  • Verified answer
    Dorinda Profile Picture
    1,512 on at

    @LaurensM thank you for pointing me in the right direction, I ended up using this solution from @mdevaney  It worked like a charm.

     

    You all rock!!

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard