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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power Automate Select ...
Power Automate
Answered

Power Automate Select Action keep rearranging key to top of the list

(0) ShareShare
ReportReport
Posted on by 20

In attempt to remove the square brackets in the CSV file exported from a Power Automate flow that I created by querying against a Power BI dataset, I used Select Action after Create CSV table and entered Key Value mappings.  Among the two dozens fields to map, there are 12 fields that are just the number 1, 2, 3, 4, etc up to 12.  The wierd thing is everytime I ran the flow, the fields 10, 11 and 12 always get shoved to the beginning of the row no matter where along the list I entered them.  I can have some text key, e.g. Name, Type, Term-Period, etc at the top of the list.  It wouldn't change on save.  It would look fine on code peek.  The test would be successful.  But the order of the output fields are messed up.

 

I am using this to produce daily report and the order of the fields is important.  I found one post that was started in 2019 and there has been no reply to it.  Is it still a bug?  Is there any work around?

Categories:
I have the same question (0)
  • Verified answer
    lbendlin Profile Picture
    8,479 Super User 2025 Season 2 on at

    same if you add a space in front of the column name?

  • johnnylo Profile Picture
    20 on at

    It will stay in the correct position but then the column name contains a space in front of the number.  If I put single quote in front or around after the number, the column name would include the single quotes the way I put them in.

    What used to happen (at least last week) is that the single digit number columns would stay in the correct order.  Only the double digit columns will be re-ordered to the front.  Now all the number columns are in the front from small to large number despite the fact that I entered them in the middle of the list in Select action.

     

    [Edit] suggestion from @lbendlin actually works.  Please see my own reply after this.  I have spent days trying to figure out different ways of removing the brackets.  Hope this also help someone else.

  • johnnylo Profile Picture
    20 on at

    I added a space in front of all the columns that are named with number.  The order of the columns are now exactly how I want them despite the column labels are ' 1' instead of '1', etc. 

    johnnylo_0-1686769556873.png

     

    However, a new problem arise from the SELECT ACTION.

     

    The query is Query Against Power BI dataset.  In the DAX query DEFINE section SELECOLUMNS, I have "Run Date",'TableName'[Run Date] as one of the fields. 

    johnnylo_1-1686769622892.png

    The output of the query contains the Run Date and all the other field names in square brackets like so.

    "[Run Date]":"2023-06-07T00:00:00"......

    The next action is SELECT in which, among the numbered columns, I have Key 'Run Date' (without single quotes) and value is item()?['[Run Date]'].  In the Input of the SELECT action, it shows the value of the field like so

    {"from":[{"[Run Date]":"2023-06-07T00:00:00".........

    In the Output, the value of the field is stripped like so

    {"body":[{"Run Date":null,......

    for all the Run Date fields in all the records.

    If I skip the SELECT ACTION (so Query, then create CSV table, then create file), the file contains the right value for Run Date. 

    Am I missing some formating syntax in the expression?

    Thanks for your help.

  • johnnylo Profile Picture
    20 on at

    One of my colleagues looked at it and saw my typo in SELECT ACTION for Run Date.  Once I fixed the typo it found all the data.  Also with a space in front of the number in the Key, the CSV output contains a space between the comma and the number.  Then the CSV File created after that contains the columns in the correct order and column names with just the number not the space.

     

    Thanks @lbendlin.  It works.  Though I am trying to understand the machanism if someone can help explain or direct me to some readings.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard