office365power-automatepower-automate-desktop

Extract Value from Array in Power Automate


I have an array as:

[
  {
    "Name": "Ca_somethingunkown"
  },
  {
    "Name": "Mv_somethingunkown"
  }
]

Am trying to get output in Power Automate as only "Mv_somethingunkown", while just searching as Mv as the array will be dynamic and after Mv the text will be changed everytime.

I tried Filter Array, Compose, Select, Startswith, Contains. But Either am getting again array as result or no output.

Expression I used in Filter Array is: @startwith(['Name'],'Mv')

Update

Post updating expression per Skin's Answer the Output is per below:

{
    "body":  [
        {
            "Name":"Mv_somethingunkown"
        }
    ]
}

I was trying to get the desired output as only "Mv_somethingunkown" as a string and no more arrays.


Solution

  • I can only suggest that you're not applying the expression(s) correctly ...

    Flow

    This is the Filter Array step ...

    Filter Array

    ... the expression on the left is ...

    item()['Name']
    

    ... so the entire expression in advanced terms is ...

    startsWith(item()['Name'],'Mv')
    

    Then to extract just the value, use an expression like this in a Compose operation ...

    first(body('Filter Array'))['Name']
    

    ... or ...

    body('Filter Array')[0]['Name']