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 / Updating variable valu...
Power Automate
Unanswered

Updating variable values to a data table

(0) ShareShare
ReportReport
Posted on by 61

Hello, 

 

can someone help with inserting a row into datatable with values to be passed as variables? I am using the command insert row into data table , but need the correct syntax to pass variables as values. 

 

Thanks. 

I have the same question (0)
  • WillSG Profile Picture
    352 Moderator on at

    Hi @Sh99  I hope you are doing well.

     

    I will assume that you are using the For Each Action which will give us the variable %CurrentItem%.

    Now, PAD listing is based 0, that means that if you have 5 columns with data, the numbers assigned to each column would be 0,1,2,3,4.

     

    So, when you have data into the %CurrentItem% and let’s assume that your data goes like this, Name, Last Name, Address, Phone and Email, the values will be assigned to the variable in this order:

    • Name: %CurrentItem[0]%
    • Last Name: %CurrentItem[1]%
    • Address: %CurrentItem[2]%
    • Phone: %CurrentItem[3]%
    • Email: %CurrentItem[4]%

     

    Again, I’m assuming here because there is not enough information, but if you ever work with the For Each action, the steps above will help you accomplish the automation.

     

    Please let me know if it works, happy automation!,


    If I have addressed your inquiry successfully, kindly consider marking my response as the preferred solution. If you found my assistance helpful, a 'Thumbs Up' would be greatly appreciated.

     

    Additionally, I offer specialized consultancy and development services leveraging PAD. If you're interested in exploring these services further, feel free to DM me, and we can initiate a discussion.

     

    Kind regards,

     

    Will SG

    Managing Director & Automation Lead

    RAMS CR (Recruitment & Automation)

    LinkedIn Profile

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @Sh99 @Hope you are doing well!!

     

    please share some screenshot to understand your flow logic and errors?

     

    Thanks

    Deenu

  • Sh99 Profile Picture
    61 on at

    Hello please refer to the attached screenshot, in the last command, insert row into datatable , What is the syntax to add varaibles as values? 

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @Sh99. Please follow the below method to add your variable values into your data table.

    Deenuji_0-1708003630783.png

    Code:

    SET EmpName TO $'''Deenu'''
    SET Age TO 18
    Variables.CreateNewDatatable InputTable: { ^['EmpName', 'EmpID'], [$'''''', $''''''] } DataTable=> DataTable
    SET DataTable TO DataTable + [EmpName, Age]

     

    Thanks,

    Deenu

  • Sh99 Profile Picture
    61 on at

    okay , could you please show me the next command as well what you have put for values in insert row command?

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @Sh99 - Adding variables directly into the insert row action is not accepted. Therefore, I utilized the set variable action in the command above. However, if you still wish to add your data through the insert row action, please review the details below.

    According to Microsoft documentation, the insert row action in DataTable only accepts two data types: List or DataRow. Please refer to the following link for more information:

     

    Variables actions reference - Power Automate | Microsoft Learn


    I have implemented the same in the example use case below, and it works when passing data row or List. Please review it:

    Deenuji_0-1708010552354.png

     


    Code:

    Variables.CreateNewDatatable InputTable: { ^['EmpName', 'EmpID'], [$'''''', $''''''] } DataTable=> DataTable
    Variables.CreateNewList List=> ListEmpName
    Variables.CreateNewList List=> ListEmpAge
    Variables.AddItemToList Item: $'''Deenu''' List: ListEmpName
    Variables.AddItemToList Item: $'''Loganathan''' List: ListEmpName
    Variables.AddRowToDataTable.AppendRowToDataTable DataTable: DataTable RowToAdd: ListEmpName
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Deenu\\Accounts_Details.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance ReadAsText: False FirstLineIsHeader: False RangeValue=> ExcelData
    SET EmpName TO $'''Deenu'''
    SET Age TO 18
    SET DataTable TO DataTable + [EmpName, Age]
    LOOP FOREACH CurrentItem IN ExcelData
    Variables.AddRowToDataTable.AppendRowToDataTable DataTable: DataTable RowToAdd: CurrentItem
    END

    Thanks,

    Deenu

    -----------------------------------------------------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up. Thank you.

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard