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 Automate / Converting excel data ...
Power Automate
Answered

Converting excel data table

(0) ShareShare
ReportReport
Posted on by 54

Hi all, 

 

I have this type of data table 

jthacker_0-1684410167172.png

 

and I need to convert it to this type. 

jthacker_1-1684410254737.png

Any help will be appreciated. 

 

Thank you!

 

I have the same question (0)
  • jthacker Profile Picture
    54 on at

    Correction, this should be the input file.

     

    jthacker_0-1684415375342.png

     

    Thank you. 

     

     

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @jthacker 

     

    Try this flow 

     

    Nived_Nambiar_0-1684464735102.png

     

    Nived_Nambiar_1-1684464762009.png

     

    Nived_Nambiar_2-1684464781016.png

     

     

    Here I have used the below file 

    Nived_Nambiar_3-1684464806853.png

     

    it writes the output into same file in sheet2

    Nived_Nambiar_4-1684464832269.png

     

    Good thing is that it work when you add one more store let's say Store 6

     

    Take this as an input sheet

    Nived_Nambiar_5-1684464889824.png

     

    After running bot, you will get like this 

    Nived_Nambiar_6-1684465002640.png

     

     

    Copy the below code and paste in power automate desktop  to get the above code 

     

    SET ExcelFile TO $'''C:\\Users\\User1\\Desktop\\Temp\\sample_file.xlsx'''
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: ExcelFile Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
    Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: FirstFreeColumn - 1 EndRow: FirstFreeRow - 1 ReadAsText: True FirstLineIsHeader: True RangeValue=> ExcelData
    Excel.CloseExcel.Close Instance: ExcelInstance
    SET FinalDT TO { ^ExcelData.Columns }
    SET ColsList TO ExcelData.Columns
    Variables.RemoveItemFromList.RemoveItemFromListByIndex ItemIndex: 0 List: ColsList
    Variables.CreateNewList List=> TempList
    LOOP FOREACH row IN ExcelData
    LOOP index FROM 1 TO ColsList.Count STEP 1
    LOOP LoopIndex FROM 1 TO ExcelData.Columns.Count STEP 1
    Variables.AddItemToList Item: $'''%''%''' List: TempList
    END
    SET TempList[0] TO row['Fruits']
    SET TempList[index] TO row[index]
    SET FinalDT TO FinalDT + TempList
    Variables.ClearList List: TempList
    END
    END
    SET emptydt TO { ^ExcelData.Columns, ExcelData.Columns }
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: ExcelFile Visible: True ReadOnly: False Instance=> ExcelInstance2
    Excel.AddWorksheet Instance: ExcelInstance2 Name: $'''Sheet2''' WorksheetPosition: Excel.WorksheetPosition.Last
    Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance2 Name: $'''Sheet2'''
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance2 Value: emptydt Column: $'''A''' Row: 1
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance2 Value: FinalDT Column: $'''A''' Row: 2
    Excel.CloseExcel.CloseAndSave Instance: ExcelInstance2

     

     

     

     

    Hope this helps !

     

    Mark it as solution if it resolves your query !

     

  • jthacker Profile Picture
    54 on at

    Thank you  @Nived_Nambiar 

     

    Just in case I have this data table.

    jthacker_1-1684502994555.png

     

    And I want to do a similar thing, like the table below.

    Which activity from the solution should I change?

    jthacker_2-1684503080947.png

     

    Regards, 

     

     

  • jthacker Profile Picture
    54 on at

    Hi @Nived_Nambiar 

     

    Aside from having the 'Fruit No.' and 'Fruit' I also want to delete rows with that does that not have any value. Please see sample tables below. 

    jthacker_3-1684503898849.png

     

    jthacker_4-1684504058712.png

    Let me know if I should post this as a different topic. I'd be happy to accept the solution you provided for the original post. 

     

    Thanks again. 

     

     

  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @jthacker 

     

    No need to create another topic for this 🙂

     

    Here is answer for your 2 replies before 🙂

     

    see below flow 

     

    Nived_Nambiar_0-1684520786449.png

     

    Nived_Nambiar_1-1684520807404.png

     

    Nived_Nambiar_2-1684520824744.png

     

     

    Input sheet 

     

    Nived_Nambiar_3-1684520844247.png

     

    Output sheet

    Nived_Nambiar_4-1684520857564.png

     

     

    Copy the flow code from below

     

     

    SET ExcelFile TO $'''C:\\Users\\sample_user\\Desktop\\Temp\\sample_file.xlsx'''
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: ExcelFile Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
    Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: FirstFreeColumn - 1 EndRow: FirstFreeRow - 1 ReadAsText: True FirstLineIsHeader: True RangeValue=> ExcelData
    Excel.CloseExcel.Close Instance: ExcelInstance
    SET FinalDT TO { ^ExcelData.Columns }
    SET ColsList TO ExcelData.Columns
    Variables.RemoveItemFromList.RemoveItemFromListByIndex ItemIndex: 0 List: ColsList
    Variables.RemoveItemFromList.RemoveItemFromListByIndex ItemIndex: 0 List: ColsList
    Variables.CreateNewList List=> TempList
    LOOP FOREACH row IN ExcelData
    LOOP index FROM 1 TO ColsList.Count STEP 1
    LOOP LoopIndex FROM 1 TO ExcelData.Columns.Count STEP 1
    Variables.AddItemToList Item: $'''%''%''' List: TempList
    END
    IF IsNotEmpty(row[index + 1]) THEN
    SET TempList[0] TO row['Fruit No.']
    SET TempList[1] TO row['Fruits']
    SET TempList[index + 1] TO row[index + 1]
    SET FinalDT TO FinalDT + TempList
    END
    Variables.ClearList List: TempList
    END
    END
    SET emptydt TO { ^ExcelData.Columns, ExcelData.Columns }
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: ExcelFile Visible: True ReadOnly: False Instance=> ExcelInstance2
    Excel.AddWorksheet Instance: ExcelInstance2 Name: $'''Sheet2''' WorksheetPosition: Excel.WorksheetPosition.Last
    Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance2 Name: $'''Sheet2'''
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance2 Value: emptydt Column: $'''A''' Row: 1
    Excel.WriteToExcel.WriteCell Instance: ExcelInstance2 Value: FinalDT Column: $'''A''' Row: 2
    Excel.CloseExcel.CloseAndSave Instance: ExcelInstance2

     

     

     

    Hope it helps !

     

     

  • jthacker Profile Picture
    54 on at

    Thank you @Nived_Nambiar 

    You've been very helpful. 

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 229 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 227

#3
Haque Profile Picture

Haque 181

Last 30 days Overall leaderboard