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

Community site session details

Session Id : fPRNYaX3Y/lAOjpzhDsRUu
Power Automate - General Discussion
Answered

Converting an input format to another format

Like (0) ShareShare
ReportReport
Posted on 2 Oct 2023 14:15:04 by 72

Hi:

I have the following format in the flow (below) and needed to convert to another format (below - Output). Is this possible?

Format in Flow:

[

  {
    "FileName": "abc.pdf",
    "rpa": "true"
  },
  {
    "FileName": "abc.pdf",
    "robotic process automation": "true"
  },
  {
    "FileName": "abc.pdf",
    "process automation": "true"
  },
  {
    "FileName": "pqr.pdf",
    "rpa": "true"
  },
  {
    "FileName": "pqr.pdf",
    "robotic process automation": "false"
  },
  {
    "FileName": "pqr.pdf",
    "process automation": "true"
  }
]

 

But need to convert to this format (output):

[
  {
    "FileName": "abc.pdf",
    "rpa": "true",
    "robotic process automation": "true",
    "process automation": "true"
  },
  {
    "FileName": "pqr.pdf",
    "rpa": "true",
    "robotic process automation": "false",
    "process automation": "true"
  }
]

  • Tak103 Profile Picture
    72 on 09 Oct 2023 at 11:55:45
    Re: Converting an input format to another format

    Thanks. This works

  • Verified answer
    SudeepGhatakNZ Profile Picture
    14,381 Most Valuable Professional on 03 Oct 2023 at 01:10:58
    Re: Converting an input format to another format

    @Tak103 ,

     

    You could try converting the following Powershell code into workflow logic.

     

    $json = @"
    [
    {
    "FileName": "abc.pdf",
    "rpa": "true"
    },
    {
    "FileName": "abc.pdf",
    "robotic process automation": "true"
    },
    {
    "FileName": "abc.pdf",
    "process automation": "true"
    },
    {
    "FileName": "pqr.pdf",
    "rpa": "true"
    },
    {
    "FileName": "pqr.pdf",
    "robotic process automation": "false"
    },
    {
    "FileName": "pqr.pdf",
    "process automation": "true"
    }
    ]
    "@

    $data = ConvertFrom-Json $json

    $result = @{}
    $data | ForEach-Object {
    $fileName = $_.FileName
    if (-not $result.ContainsKey($fileName)) {
    $result[$fileName] = @{
    "FileName" = $fileName
    }
    }
    foreach ($key in $_.PSObject.Properties | Where-Object { $_.Name -ne "FileName" }) {
    $result[$fileName][$key.Name] = $key.Value
    }
    }

    $finalResult = $result.Values

    $finalResult | ConvertTo-Json
  • AndrewR1 Profile Picture
    1,572 Moderator on 02 Oct 2023 at 15:16:07
    Re: Converting an input format to another format

    Hi @Tak103 I'm not sure this is the best way to approach for this can you not change the way the information is passed to the Power Automate?

     

    Have this in the correct format rather than having multiple lines for each pdf can you not collect this together and then pass it as the desired output? Doing this dynamically would prove difficult? 

     

    Try passing information as this in the 1st instance: 

    [
    {
    "FileName": "abc.pdf",
    "rpa": "true",
    "robotic process automation": "true",
    "process automation": "true"
    },
    {
    "FileName": "pqr.pdf",
    "rpa": "true",
    "robotic process automation": "false",
    "process automation": "true"
    }
    ]

     

    I did try using Select data operation but this wouldn't give me the desired out put this would just create multiple PDF items and append the additional columns as null values:

     

    AndrewR1_0-1696259628702.png

     

    Sorry I couldn't help any further 

    Andrew 

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2