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 / Building flow from a S...
Power Automate
Unanswered

Building flow from a SharePoint list to a create a CSV file

(0) ShareShare
ReportReport
Posted on by 25

Hi all.  Wondering if anyone would know how to help me on this one.

 

I have an SharePoint list where I input Employee information, Name, User ID, Hire date etc...

 

I have built an automated cloud flow that gets triggered when new employee information is entered on this list, and stores the information onto a CSV file in a document library, then emails that CSV files to people.

 

Currently, ALL of the data on the SharePoint list gets added to the CSV file, I only want NEW data to to appear on the CSV file.

 

I have tried multiple conditions, but none seem to work, I think what I need is one that is: Created by is equal to "Todays Date"

 

does anyone know how to do this?  I cant seem to find an expression that matches exactly

Categories:
I have the same question (0)
  • nitishsh91 Profile Picture
    200 on at

    Hi @cmacdonald 

    You can use the "Filter array" action to filter the SharePoint list items based on the "Created" date field. The "Filter array" action takes two inputs: the array to be filtered and the condition to filter by. The condition is an expression that evaluates to true or false for each item in the array.

     

    Here is an example of how you can use the "Filter array" action to filter the SharePoint list items based on the "Created" date field:

     

    First, you will need to retrieve the SharePoint list items using the "Get items" action.

     

    Next, add a "Filter array" action and connect it to the output of the "Get items" action.

     

    In the "Filter array" action, set the "From" field to the output of the "Get items" action.

     

    In the "Filter array" action, set the "Filter Query" field to the following expression:

    Created eq '{{utcNow()}}'

     

    This will filter the SharePoint list items to only include items that have been created on the same day as the flow is running.

     

    Next, you can use the "Create CSV table" action to create a CSV file from the filtered SharePoint list items.

     

    Finally, you can use the "Send an email" action to email the CSV file to the desired recipients.

     

    Note: If you are using SharePoint online, you can also use the OData filter query to filter the items based on date, like ?$filter=Created eq '2022-12-01T05:00:00Z'

     

    It is important to note that the above solution assumes that the "Created" date field is being used to store the date when the list item was created. If your SharePoint list is using a different field to store this information, you will need to adjust the expression accordingly.

  • cmacdonald Profile Picture
    25 on at

    Thanks.  That still gave me everything in the SP list.  

    This is what I have in as the flow

     

    cmacdonald_0-1674525876672.png

     

     

     

     

  • Verified answer
    nitishsh91 Profile Picture
    200 on at

    It looks like you are using the "Get Items" action to retrieve all items from the SharePoint list, and then using the "Filter array" action to filter out items that are not equal to today's date.

    Instead, you can use the "Filter query" option in the "Get items" action to filter the items that are retrieved from the list. This way, you are only retrieving the items that you need, and you don't have to filter them out afterwards.

    In the "Get items" action, change the "Filter query" to: Created eq '{utcnow('yyyy-MM-dd')}'

    This will filter the SharePoint list items to only include those that have been created today, and the rest of your flow will be using only those new items.

    Also make sure you're using the correct date format based on the date format in your SharePoint list.

  • grantjenkins Profile Picture
    11,063 Moderator on at

    @cmacdonald Are you sending the CSV file out daily with all items created say in the last 24 hours, or something like that? If that's what you're after, then this is how I'd build the flow.

     

    Note that if there haven't been any items created in the last 24 hours, then it could just not send an email, or still send an email saying no new items created today (up to you on what you would want to do in that instance). In my example, I don't send an email unless there is at least one new item.

     

    For this example, I'm using the following list.

    grantjenkins_1-1674562031239.png

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_2-1674562576561.png

     

    Recurrence will trigger my flow every day at 8AM. You can set whatever suits your requirements.

    grantjenkins_3-1674562623253.png

     

    Get items will retrieve my list items, but only the items that were created in the last 24 hours. Since our Created field contains both the date and the time the item was created, we need to use an expression to check between two date/times. The expression used for the Filter Query here is below. It checks if the items were created after 1 day ago, and before the current date/time - so in the last 24 hours.

    //You can just copy/paste this directly into the Filter Query box
    
    Created ge '@{addDays(utcNow(), -1)}' and Created lt '@{utcNow()}'

    grantjenkins_4-1674562816240.png

     

    Condition checks to see if any items were returned (any items were created in the last 24 hours). We use the length expression to check the length of items returned. If the length is greater than 0 then we know at least one item was created, so we can build our CSV table and send the email. The expression used in the condition is:

    length(outputs('Get_items')?['body/value'])

    grantjenkins_5-1674562928764.png

     

    If the condition was true, we go into the Yes branch.

     

    Create CSV table uses the output from Get items and maps the fields we want to include in our CSV table.

    grantjenkins_6-1674563000275.png

     

    Send an email will send an email with the CSV table attached. Note that we also need to include a name for the CSV including the file extension. In my example, I've called it Records.csv.

    grantjenkins_8-1674563128940.png

     

    After running the flow, we would end up with an email similar to the one shown below.

    grantjenkins_9-1674563195378.png

     

    Note - if you wanted to send a different email when no items were created in the last 24 hours, you could add another Send an email action within the No branch that said no new items, or similar.


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • cmacdonald Profile Picture
    25 on at

    @grantjenkins that worked.  Thanks.  One other question.  how would i write the filter query to give me entries that were created only today?  not 1 day ago until today

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    You can use the following expression where it gets the start of the current day, and the start of tomorrow, then checks if the date is between those two dates.

     

    Created ge '@{startOfDay(utcNow())}' and Created lt '@{startOfDay(addDays(utcNow(), 1))}' 

     

    However, in this scenario you need to be aware that if you run the flow at 6PM each day you may miss items. It will only retrieve the items created up until 6PM each day, so when it runs the next day, it won't get any items that were created after 6PM (the last time the flow ran) since they were created the day before.

     

    If you want to ensure you get all items created that day, you'd need to run your flow at the end of the day (just before midnight). I'd still suggest just getting items created in the last 24 hours, so you never miss any items.

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