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 / Extracting invoice ite...
Power Automate
Unanswered

Extracting invoice items from list items with the Power Automate Invoice Processing

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello forum members,

 

I'm seeking help with a specific task, and I've already followed (successfully) a guide to extract common invoice data. However, what I need help with now is extracting line items and adding them (column by column) to an Excel sheet in Sharepoint.

 

The item list appears to be read correctly, containing 5 items with their respective amounts.

arneulland_0-1690287753010.png

The flow of the process is as follows:

arneulland_1-1690287804060.png

arneulland_2-1690287825499.png

arneulland_3-1690287852902.png


The problem

I'm facing a challenge in getting the specific line items to be added to the Excel sheet properly. The current output either exports all together in one column (if using the line item all columns dynamic array) or doesn't produce the desired result.

 

Goal:
Per new invoice I want the excel sheet to create a new row where the line item amount is imported correctly to the specific column which corresponds with the line item description. If nothing is found then 0 or empty is okey.

It would then look like this (assuming 5 line items)

 

arneulland_1-1690291075904.png

 

 

At the moment, the situation looks like a mess:

Uten navn.png

PS: I have not found a way to manually create dynamic content per header/line item description and I suspect that is the main issue. Said differently, I cannot add line_item_amount per line item description and that is the problem.

arneulland_5-1690288248735.png

 

I would greatly appreciate any guidance or suggestions to help me achieve the desired output. Thank you in advance for your assistance!

Categories:
I have the same question (0)
  • JGT Profile Picture
    32 on at

    One thing I've had to do in the past with data that may be formatted weirdly to get the desired output is converting the data to JSON then using instead of the HTML table to get the variables you are looking for using the Parse JSON function to get the desired output with variables. 

    Without knowing exactly what that variable looks like before outputting to the excel file. I'd suggest using Bing Chat to say something like "parse this json data (copy paste the output of the json step) to an excel file. I've had pretty good success with that output being able to parse complex tabled data. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Interesting. ChatGPT also suggested using variables as a fix:

    Step 1: Set up AI Builder in Power Automate (if not done already).

    • Ensure that you have access to AI Builder in your Power Automate subscription.

    Step 2: Create a new Power Automate flow.

    Step 3: Select a trigger for the flow.

    • Use a trigger that corresponds to the method of importing invoices. For example, you can use the "When an email with an attachment is received" trigger if you receive invoices via email.

    Step 4: Add an action to extract invoice data using AI Builder.

    • Add an action using the AI Builder "Extract data from forms" or "Process and save the data" action. This will allow you to extract data from the invoice document.

    Step 5: Configure AI Builder action.

    • Select the appropriate model for invoice processing and map the fields you want to extract, such as line item amounts.

    Step 6: Initialize a variable to store the extracted line items.

    • Add an action to initialize a variable to store the line items. Use the "Initialize variable" action and set it to an array type.

    Step 7: Loop through the extracted data (Apply to each).

    • Since the extracted data may contain multiple line items, use the "Apply to each" action to loop through each line item.

    Step 8: Add actions to append line item data to the variable.

    • Within the loop, use actions like "Append to array variable" to add the line item data to the variable. Map the extracted line item amounts to the appropriate column headers in the variable.

    Step 9: Add an action to update the SharePoint Excel table.

    • After the loop, use the "Update a row" action in SharePoint to update the Excel table with the line item data stored in the variable. Map the data from the variable to the corresponding columns in the SharePoint Excel table.

    Step 10: Complete the flow.

    • After adding all the necessary actions, save and test your flow to ensure that it extracts the line items and updates the SharePoint Excel table correctly.

    By following these steps, you should be able to extract line items from the invoice using AI Builder and populate the SharePoint Excel table with the extracted data in an orderly fashion. Make sure to review the actions and adjust the flow based on your specific requirements and the AI Builder model you are using.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Testing with variables now but cannot see how I can create names per variable so that I know which one belongs to which line item.

    arneulland_0-1690290533554.png

     

  • JGT Profile Picture
    32 on at

    The way that is happening you are initializing variables for each item, initialize the variable here

    JGT_1-1690299592946.png

    then append your array where you are currently initializing it. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi,

    What should I choose in this instance to give the variable a value that fits (there is no way to connect to the line items and specify which amount I want to set the variable as)

    arneulland_0-1690306611269.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    The above refers to the fact that I cannot find a way to set a variable to "each item" as there is no way to distinguish the items. 

     

    The dynamic array just state "line item amount (text)".

  • JGT Profile Picture
    32 on at

    You will initialize the variable like you are doing, add the items in the loop like you had it before to "add those items" then call that variable later. So for example the order would be:
    1. Create the variable
    2. add all the items to the variable
    3. do any formatting you need to on the variable you added items to
    4. use the variable

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Unfortunatly cannot follow your suggestion.
    1) I do the following to create the variable (the apply to each comes automatically when using line item)

    Skjermbilde 2023-07-25 203649.png

    2) When trying to use the variable again  it's impossible

    Skjermbilde 2023-07-25 203838.png
    Also tried to save but get the following error: Flow save failed with code 'InvalidVariableInitialization' and message 'The variable action 'Initialize_variable_2' of type 'InitializeVariable' cannot be nested in an action of type 'Apply_to_each_3'.'.

  • JGT Profile Picture
    32 on at

    Here I show you 🙂 I created an example array "data" with the  [red,green,blue] in an earlier step. Then initialized a blank array, incremented the new blank array in a loop FOR all the items in "data" and sent a teams message to myself of the current item in the array its LOOPING through. 

    JGT_1-1690311265582.png

    The teams messages I got looks like this:

    JGT_2-1690311374155.png


    Does that make more sense? The value of the array named "Add Data to me" would be [red,green,blue] now as well.

  • JGT Profile Picture
    32 on at

    Also to note, in your example where you need to do some formatting to "sanitize" the data before inputting it to an excel file. You will want to do the formatting before you add the variable to the append array variable. If you don't want to use an "Array" and instead would use an "object", you can hand it json data which seems in my experience to be handled better by Power Automate. 

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 410

#2
Vish WR Profile Picture

Vish WR 289

#3
David_MA Profile Picture

David_MA 282 Super User 2026 Season 1

Last 30 days Overall leaderboard