Skip to main content

Notifications

Community site session details

Community site session details

Session Id : tUb/TFEzlxh94oWo0m9cLD
Power Automate - Building Flows
Answered

create a csv table with multi row header

Like (0) ShareShare
ReportReport
Posted on 5 Dec 2020 18:40:18 by 11

Hello,

 

I need to create a csv table which has a specific format / template with a 3 row header, for each column (like shown above).

 

StartDateStatusCall_SIDInteraction_ID
Start DateResponse TypeCall_SIDInteraction_ID
{"ImportId":"startDate","timeZone":"Europe/London"}{"ImportId":"status"}{"ImportId":"Call_SID"}{"ImportId":"Interaction_ID"}
«values»«values»«values»«values»

 

This is a specific format we use to import legacy data.

The first three rows are considered header for my platform. As the values are only expected in the 4th row of the file.

 

I have managed to create the csv all right with the right data in the value cells. All except for the header that I can't manage to have in 3 different rows / cells (all I could manage was to have all strings in the same cell).

 

Can you please advise on a way to achieve this?

  • Verified answer
    fchopo Profile Picture
    7,968 Super User 2025 Season 1 on 07 Dec 2020 at 20:14:58
    Re: create a csv table with multi row header

    Hello @sandracosta 

    I did a test on my side that it is working:

    headers.png

     

    In this example, we have an excel file with 2 columns (Region, Country). The steps are:

     

    1) Define headers (3 rows)

    2) List Excel Rows

    3) Select the Region and Country columns

    4) Create a CSV table

    5) Replace "Region,Country" string by the headers.

     

    Hope it helps!

    Ferran

  • sandracosta Profile Picture
    11 on 07 Dec 2020 at 18:33:22
    Re: create a csv table with multi row header

    Hello @fchopo and @fchopo 

     

    Thanks so much for your fast replies.

    I tried to go in the direction you appointed but I guess I am not as proficient in Power Automate as I should have been to solve this flow. My flow only got to this:

    sandracosta_0-1607365855589.png

     

    This flow stops in the “csv table” creation with the error “The property 'columns' must be specified unless the 'from' property value is an array of objects.”.  However, in the last compose output I don’t seem able to identify the columns and hence can’t specify them.

     

    The output from the union / input to the csv table comes out like this:

    [

      [

        "StartDate",

        "EndDate",

        "Q1",

        "Q2"

      ],

      [

        "Start Date",

        "End Date",

        "De 0 a 10 indique pf como recomendaria a Galp aos seus amigos e familiares, com base na sua experiĂŞncia com este serviço de atendimento (em que 0 Ă© nĂŁo recomendaria e 10 Ă© recomendaria de certeza)",

        "De 1 a 5 indique pf o seu grau de satisfação com o atendimento que acabou de ter? (em que 1 Ă© Muito Insatisfeito e 5 Ă© Muito Satisfeito)"

      ],

      [

        "{\"ImportId\":\"startDate\",\"timeZone\":\"Europe/London\"}",

        "{\"ImportId\":\"endDate\",\"timeZone\":\"Europe/London\"}",

        "{\"ImportId\":\"QID1\"}",

        "{\"ImportId\":\"QID2\"}"

      ],

      {

        "Start": "44161.4674189815",

        "End": "44161.4674189815",

        "Q1": "9",

        "Q2": "5"

      },

      {

        "Start": "44161.7289467593",

        "End": "44161.7289467593",

        "Q1": "9",

        "Q2": "5"

      },

      {

        "Start": "44161.4358796296",

        "End": "44161.4358796296",

        "Q1": "5",

        "Q2": "2"

      },

      {

        "Start": "44161.3903703704",

        "End": "44161.3903703704",

        "Q1": "9",

        "Q2": "5"

      },

    …

     

    A problem that I had was that I wasn’t able to initiate an array type variable. I kept getting the error “The variable 'ExtraHeader' of type 'Array' cannot be initialized or updated with value of type 'String'. The variable 'ExtraHeader' only supports values of types 'Array'.” with this script.

    sandracosta_1-1607365855596.png

     

    To solve this, I composed the extra header with createArray function. And “union” it to the select of the original file. But not sure if its the best practice.

  • Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on 05 Dec 2020 at 20:34:40
    Re: create a csv table with multi row header

    You could do something like this:

    CSVHeaders.png

    Explanation:

    Create a new array that is the same format as the array that is going to be made into CSV.

    Add your additional header records into that array.

    Union that array with your existing data and then put the result into the "Create CSV Table" Step.

  • fchopo Profile Picture
    7,968 Super User 2025 Season 1 on 05 Dec 2020 at 19:14:52
    Re: create a csv table with multi row header

    Hello @sandracosta 

    Before creating the csv table, you could add 2 new rows at the top of the table, with header data in rows 2 and 3, using, for example, a compose action or appending to an array one (if you share your flow and the format of your data, we might provide more detailed information).

    Hope it helps!

    Ferran

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started