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 / How to always get the ...
Power Automate
Unanswered

How to always get the value of last column ?

(0) ShareShare
ReportReport
Posted on by 136

RookAils1_0-1709712725093.png

Greeting,

 

I have several datatables where I extracted from a PDF and each line kinda look like this. So, I would like to get the value of the last column. In this case, Column3. Sometimes, the Row could have 2 or more columns but the last column always contain the value I want, 

 

Would appreciate any help or suggestion on this matter.

I have the same question (0)
  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @RookAils1 

     

    Give this a try:

    To retrieve the number of columns from your DataTable, use `DataTable.Columns.Count`. Then, during the iteration of your DataTable using a foreach loop, you can refer to `currentItem[DataTable.Columns.Count-1]`. This will consistently return the last value of your DataRow.

     

    Deenuji_0-1709718596194.png

     

    Deenuji_0-1709726574706.png

     

     

     

     
  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @RookAils1 

    Have you attempted the provided solution? Feel free to reach out if you have any questions about it.

     

    If the solution proves effective, kindly consider marking it as the accepted answer. This will assist others in finding the solution easily through search.

     

  • RookAils1 Profile Picture
    136 on at

    Thanks for the suggestion provided. Im making progress towards it. I have a new inquiry, if I may ask, based on the screenshot I provided above, how should I combine the value form Column1 and Column2, in this case it will become "Invoice No: " 

     

    Could you assist me on this @Deenuji ?

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @RookAils1 

    Try something like below:

    CurrentItem[ExcelData.Columns.Count - 2] + CurrentItem[ExcelData.Columns.Count - 1]

     

    Deenuji_0-1709787016015.png

    Code:

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\deenu\\OneDrive\\Documents\\Invoice_Details.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance ReadAsText: False FirstLineIsHeader: False RangeValue=> ExcelData
    LOOP FOREACH CurrentItem IN ExcelData
    Display.ShowMessageDialog.ShowMessage Title: $'''Alert''' Message: CurrentItem[ExcelData.Columns.Count - 2] + CurrentItem[ExcelData.Columns.Count - 1] Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    END

     

     

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 266 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 160 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 134 Super User 2026 Season 2

Last 30 days Overall leaderboard