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 / Extract data from exce...
Power Automate
Unanswered

Extract data from excel based on max date and filter

(0) ShareShare
ReportReport
Posted on by 24

Hi,

I am quite new to power automate, and reaching out to the community if anyone could provide a solution to my query.

The automation that I am trying to develop in PAD is that I receive a weekly email containing an excel attachment, from which I require a hidden sheet where the data is stored.

 

The datasheet has several columns, with the two keys columns ‘date’ and ‘provider’, I need to only extract data that relates to Provider 1 and insert this into a master sheet and only need to extract rows where the date is greater than the max date for the provider in master file, so in this example I would only extract the rows with a date greater than 18/03/23 for provider 1 from the data sheet and insert it into the master file.

 

Data Sheet

Date

Provider

18/03/23

Provider 1

18/03/23

Provider 2

19/03/23

Provider 1

20/03/23

Provider 1

21/03/23

Provider 3

22/03/23

Provider 1

 

Master file

Date

Provider

14/03/23

Provider 1

15/03/23

Provider 1

16/03/23

Provider 1

17/03/23

Provider 1

18/03/23

Provider 1

18/03/23

Provider 4

 

I have currently set up the flow below, where I have managed to unhide the sheet and query the datasheet, in my flow I have saved a copy of the extract which I don’t necessarily need. The issue I am having is trying to find a solution to only extract the ‘query result’ data where the date is greater than the max date for that provider within my master file

 

Nagin_0-1679478220495.png

Any help on this would be much appreciated

 

Thanks

 

Nagin

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Nagin 

     

    Just to know ,

     

    is the query result is the output data from master file for a specific provider ?

     

  • Nagin Profile Picture
    24 on at

    Hi @Nived_Nambiar 

     

    The query result is from the email extract that I receive, where I have extracted the specific provider, and looking for a solution where I extract only the rows that are greater than the max date for that provider within the master file and then update the master file with the query result

     

    Thanks

     

    Nagin

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    @Nagin 

     

    What i would suggest is 

     

    once you have the query data for that provider from attachment, navigate to master excel use that provider to filter [ I would suggest to use sql approach for master datatable as it would be faster] and then sort it using dates in descending order. Then pick up the top row Date column to get the date value, That data value would be latest. Then go to query result got from email attachment, filter with the date value obtained and then add the result to datatable (master).

     

    This way you can give a try 🙂

  • Nagin Profile Picture
    24 on at

    Hi @Nived_Nambiar 

     

    Thank you for you help, I have filtered the email file and sorted by DESC and and filtered the master file and sorted by DESC and created a variable for the master file to extract the last date for that provider which is '10/03/2023'.

     

    How do I now write a variable to filter the 'emaildata' where the column for date is greater than 'lastdatemaster' and then add this to the 'masterdata'

     

    Nagin_0-1679580609804.png

     

    Thanks

    Nagin

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    I hope you can rely on SQL queries to filter emaildata again based on that date.

     

    To add the data, you can use write data to excel worksheet action

     

    Hope this helps 🙂

  • Nagin Profile Picture
    24 on at

    Hi @Nived_Nambiar 

     

    Would I able to reference my 'lastdatemaster' variable within sql statement for my 'emaildata'

    e.g SELECT * FROM [MasterData$)

    Where date>(%lastdatemaster%)

     

    Thanks

    Nagin

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    @Nagin 

     

    Just try this way as well if above one does not work 

     

    SELECT * FROM [MasterData$)

    Where date>('%lastdatemaster%')

  • Nagin Profile Picture
    24 on at

    Hi @Nived_Nambiar 

     

    Thanks it has nearly worked, I have got an error in my SQL statement for Data Type mismatch. The data column in both the email extract and master file are set as as date. However I can notice that when creating the 'lastdatemaster' variable it has left a trailing timestamp and assuming this could be the issue, is there way to remove the datestamp when creating the variable

     

    Nagin_0-1679584570045.png

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    If it is datatype mismatch, 

     

    would you try with the below sql query

     

    SELECT * FROM [MasterData$)

    Where date>(%lastdatemaster%)

     

    Regarding your question on changing date format, you can use convert text to datetime to convert to desired format

     

     

  • Nagin Profile Picture
    24 on at

    Hi @Nived_Nambiar 

    I have tried to convert text to datetime however still have a mismatch, could there be any other reasons why there would be a mismatch

    Nagin_0-1679588317439.png

    Thanks

    Nagin

     

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

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 233 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 178

Last 30 days Overall leaderboard