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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create + email Excel f...
Power Automate
Unanswered

Create + email Excel file of rows from another workbook matching multiple conditions

(0) ShareShare
ReportReport
Posted on by 55
Hi PowerAutomate community, 
I've been trying to create an automation with no success; hopefully, someone with more knowledge can help!
 
I have one Excel workbook in a SharePoint library where I store a table of master order information for current year, and in it there is a column "DaysOnSite" which calculates the # of days since the item arrived based on the date in the "ArrivalDate" column. When an order is picked up, I write the date and time in separate columns. 
 
Based on this, I am trying to create a weekly automation to create an Excel file, create a table in it, populate rows in such table, email the file to me, and then delete it. For now, I was trying to figure out how to copy columns A:P of rows (or the whole row at least) from the master file where column "DaysOnSite" is 25 days to 1000 or something after arrival (up to the beginning of the year/sheet, not counting the unarrived which count as 45283) and where the column "PickUpDate" is blank (meaning it wasn't yet picked up)—so multiple criteria. I may end up selecting only some columns depending on how it looks when it's printed. 
 
So far, I've started from scratch a few times with different actions and controls but none have been successful, even when the flow "successfully" runs. I can't even get the file created correctly—the newly created files in the SharePoint library all say they cannot be opened. I've used, List rows present in a table (query for eq 25 days, gt 25 days, etc), then Filter array (filter where PickUpDate eq null—didn't appear to work from the run flow view which included the picked up orders), Create a file (name ending with .xlsx), Create a table, Apply to each (output of List rows or Filetr array), Add a row. Also tried substituting HTML table, CSV, using Condition. 
 
I would appreciate if anyone could share advice on accomplishing this. I moreso need help setting up for collecting the data, creating the file that actually opens, creating and then populating the table with the data. I should be able to accomplish the setup of reoccurrence, send an email, and delete the file. The videos and postings I've looked over make it seem so easy, but I can't seem to get it.
 
Thank you in advance for your suggestions! Let me know if you need any clarification. 
 
Merry Christmas and Happy New Year! 🙂
Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hi @am02 

     

    Based on my understanding of your query, i am writing the of how flow should ran :

    1. Read the master table

    2. Filter the rows where DaysOnSite > 25 and <1000

    3. Filter the obtained rows based on pickup date as blank field

    4. populate the details in new table

    5. create excel file 

    6. send that file as attachment via email 

     

    Am i right ?

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • am02 Profile Picture
    55 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hello @Nived_Nambiar

    These should be the steps for the flow:

    1. Read the master table

    2. Get the rows where DaysOnSite > 25 and <1000

    3. Filter the obtained rows based on pickup date as blank field (only include rows where pickup date is blank)

    4. Create excel file

    5. Create table in excel file from step 4 (if this step is necessary)

    6. Populate the details from step 3 in new table (from step 5)

    7. Send that file as attachment via email

     

    Thanks!

    Alex

  • Verified answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hi @am02 

     

    I have prepared a demo flow for your usecase.

    See below, this is an excel file prepared for test purposes:

    Nived_Nambiar_0-1703514651632.png

     

    Now see the below flow:

    I am designing a manually trigger flow scenario 

    Step 1: List rows present in table 

    Nived_Nambiar_1-1703515715023.png

     

     

    Step 2: Use filter array action to filter rows by condition :

    DaysOnsite>25 and less than 1000 and pickupdate is blank/empty

    Nived_Nambiar_2-1703515785186.png

     

    Expression used: and(and(greater(int(item()?['DaysOnSite']), 25), less(int(item()?['DaysOnSite']), 1000)), equals(empty(item()?['PickUpDate']), true))

     

    This will give us filtered rows satisfying the condition.

     

    Step 3: Use send http request to create a blank excel file 

    Nived_Nambiar_3-1703515881259.png

     

    HTTP Request : _api/web/GetFolderByServerRelativeUrl('Shared%20Documents/Folder1')/Files/add(url='FinalOutputs.xlsx',overwrite=true)

     

    Here Shared%20Documents/Folder1 represents the folderpath where the fileshould be created and FinalOutputs.xlsx should be the filename 

     

    Step 4: use create table to create the table in newly created excel file

    Nived_Nambiar_4-1703516010522.png

     

    Expression used above to reference the file: body('Send_an_HTTP_request_to_SharePoint')?['d']?['UniqueId']

     

    Step 5: use apply to each to loop through each row of filtered action:

    Nived_Nambiar_5-1703516100885.png

     

     

    (Step 5.1 and 5.2 are inside the loop)

    Step 5.1 : use compose action to create a JSON object having details of single which is to be added in excel file like below:

    Nived_Nambiar_6-1703516224195.png

     

    Written expression within compose action like this:

    {
     "Order": @{items('Apply_to_each')?['Order']},
     "Name": @{items('Apply_to_each')?['Name']},
     "Phone": @{items('Apply_to_each')?['Phone']},
     "Article": @{items('Apply_to_each')?['Article']},
     "Email": @{items('Apply_to_each')?['Email']},
     "Delivery": @{items('Apply_to_each')?['Delivery']},
     "LOCATION": @{items('Apply_to_each')?['LOCATION']},
     "EMAILED": @{items('Apply_to_each')?['EMAILED']},
     "ArrivalDate": @{items('Apply_to_each')?['ArrivalDate']},
     "Arrived": @{items('Apply_to_each')?['Arrived']},
     "DaysOnSite": @{items('Apply_to_each')?['DaysOnSite']},
     "PickUpDate": @{items('Apply_to_each')?['PickUpDate']},
     "PickUpTime": @{items('Apply_to_each')?['PickUpTime']},
     "Employee": @{items('Apply_to_each')?['Employee']},
     "Notes": @{items('Apply_to_each')?['Notes']},
     "Column1": @{items('Apply_to_each')?['Column1']}
    }

     

    Step 5.2:  use add row to table to add row to table like below

    Nived_Nambiar_7-1703516352336.png

     

    File: body('Send_an_HTTP_request_to_SharePoint')?['d']?['UniqueId']

    Table: string(outputs('Create_table')?['body/name'])

    Row:

    Nived_Nambiar_8-1703516412717.png

     

     

    Outside the loop use delay action so to keep rows updated in the file (keep delay for one min)

    Nived_Nambiar_9-1703516477567.png

     

    Use get file content using path to get the content of updated file:

    Nived_Nambiar_10-1703516530124.png

     

    Expression used: concat('Shared Documents/Folder1/FinalOutputs.xlsx')

    In your case specify the file path where the file is stored of above path as shown above

     

    Now use send email action to send the excel file as attachment like below:

    Nived_Nambiar_11-1703516778421.png

     

    Output of the process:

    File created : 

    Nived_Nambiar_12-1703516800391.png

     

    Email send:

    Nived_Nambiar_13-1703516813921.png

     

     

    Hope it helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • am02 Profile Picture
    55 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hi @Nived_Nambiar,

    Thanks so much for the demo flow! 

     

    I tried implementing it as described but ran into an error under the Create table action:

    CreateTableError.PNG

     

    This is what I had filled into the Create table action:

    Create table.PNG

     

    For the List rows present in a table:

    List rows present in a table.PNG

     

    For the Filter array:

    Filter array.PNG

     

    For the Send an HTTP request to SharePoint:

    Send an HTTP request to SharePoint.PNG

    Before the Create table error, a blank Excel file was created in the correct location, but no table was created in the file and so the next steps couldn't be completed to test. 

     

    For the Compose action, would it work the same if I replaced this with a Select action? I'm finding it difficult to use the correct JSON format; getting a must be valid JSON error if I try to change what you typed for me. 

     

    Do you have any suggestions? Thank you again for your help!

     

    Alex

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hi @am02 

     

    let's resolve the create table action issue, could you tell me what dynamic content you have used in file field , is it Body dynamic content ?

    Nived_Nambiar_0-1703697771273.png

     

    Refer the flow which i have designed :

    Nived_Nambiar_1-1703697872329.png

     

    From the body of http request output, there is an ID attribute which represents the id of file created, that has to be used 

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

     

     

     

     

     

     

     

     

     

     

     

     

  • am02 Profile Picture
    55 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hi @Nived_Nambiar

    The dynamic content selected was the Body output from the Send HTTP action. This was the only dynamic option available for me to choose from that action. Did you have and Id output to select? 

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hi @am02 

     

    Refer my answer, as you can see body is only dynamic content from the send http request, but i have written an expression which helps to extract Id attribute from it. see the demo flow example as seen in below screenshot, you will get a complete idea.

    Nived_Nambiar_0-1703699707181.png

     

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • am02 Profile Picture
    55 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hi @Nived_Nambiar,

    I did also try only pasting your expression into the File field. And not adding the Body dynamic content. 

    Can you clarify; did you paste that expression ONLY? And not add any dynamic content? 

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Hi @am02 

    You have to write the expression which i have shared in expression tab as you see in my workflow corresponding to file field and click OK. then that expression appears there.

     

    Yes i have used body as dynamic content while writing expression.

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • am02 Profile Picture
    55 on at
    Re: Create + email Excel file of rows from another workbook matching multiple conditions

    Thank you, @Nived_Nambiar. I thought I tried that, but I will try again tomorrow and let you know that it works! 

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

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard