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 / Filter query of excel ...
Power Automate
Unanswered

Filter query of excel list rows on month and year of a date column

(0) ShareShare
ReportReport
Posted on by 4

Hello, 

I am trying to build a flow that sends a reminder once a month to all of the people that have a DueDate this month. I have set a Recurrence flow that works, but I am trying to use variables to avoid adding a 'Reminder Date' column to my excel table.

To do so I have set a variable that gets me  the current month and year : 

formatDateTime(convertFromUtc(utcNow(),'Romance Standard Time'),'MM-yyyy')
Theodora_0-1687358964488.png

Then in my List rows, I have this filter query : 

'formatDateTime(item()['DueDate'],'MM-yyyy')' eq CeMois
Theodora_1-1687359108593.png

However I get this error message : 

Unable to process template language expressions in action 'List_rows_present_in_a_table' inputs at line '0' and column '0': 'The template language expression 'formatDateTime(item()['DueDate'],'MM-yyyy')' cannot be evaluated because property 'DueDate' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.

 

Is there a way to fix my mistake ? I know that my flow works without a variable by adding a reminder date column and comparing it to today's date, but I would like to minimize the data preparation part.

Categories:
I have the same question (0)
  • SwJ23 Profile Picture
    85 on at

    Well, there may be something else wrong, but you're missing a "?" in your query:

     

    'formatDateTime(item()['DueDate'],'MM-yyyy')' eq CeMois 

     

    Should Be:

     

    'formatDateTime(item()?['DueDate'],'MM-yyyy')' eq CeMois

     

    That "?" from what I can tell is how you drill down in an object to select a property.

     

    Also, and this may be more important, what item() are you selecting? I don't see an Apply to Each loop in here, and item() isn't necessary otherwise. If you're trying to filter the excel table by row, you put column names in there. Your query may very well be this, or something similar:

     

    'formatDateTime(['DueDate'],'MM-yyyy')' eq CeMois

     

    And at worst, you could manipulate the CeMois to match the format of DueDate column so that your query is more simple:

    DueDate eq '@variables('CeMois')

     

  • Theodora Profile Picture
    4 on at

    Hi @SwJ23 , thank you for your answer! 😊

    I did not know what the question mark was for in this type of query, so thank you for the information 😁

    I tried using your solutions, but I got other types of errors.

     

    When using this query: 

    'formatDateTime(item()?['DueDate'],'MM-yyyy')' eq CeMois 

    I get the following error : 

    Theodora_0-1687363804783.png

    Error details: One or more fields provided is of type 'Null', a different type is expected.

     

    I have checked and my 'DueDate' column is of Date format in excel, I do not understand this error.

     

     

    When trying to use this query : 

    'formatDateTime(['DueDate'],'MM-yyyy')' eq CeMois

     

    I get and error saying the expression is invalid, I had tried this expression and gotten the same error before so I figured that I had to put Item in front of the column name for the query to work.

     

     

    Lastly I need the full 'DueDate' in my table because I am sending a reminder with the full date in it, and the day of the task is important, so I don't think I can match it to the format of the variable.

     

     

  • SwJ23 Profile Picture
    85 on at

    Here's the part I dont know (yet): how to put a column name inside a function in the expression builder for a filter query. 

    I tested a filter query in excel connector as so: 

    SwJ23_0-1687367692952.png

    against this table

    SwJ23_1-1687367709792.png

     

    and got this JSON data from the outputs:

    SwJ23_2-1687367728516.png

     

    So I know that writing the column name into the filter query works fine. Now to sort out how to nest that inside a function (this is why my last suggestion of having the column name be plain and adjusting what you filter against)

     

     

     

  • SwJ23 Profile Picture
    85 on at

    Try using the expression below:

     

    SwJ23_3-1687368223797.png

     

     

    Since your due date just needs to contain the month and year, you can just use the due date in whatever its native format is and format the CeMois date to match part of the due date string. 

     

    ie

     

    DueDate = 01/07/2023

    CeMois = formatdatetime(convertfromutc(utcnow(),'Romance Standard Time'),'MM/yyyy'))

     

    In other words, you might be able to use contains instead of a more direct filter like equals.

     

    If you can show me the native format of DueDate I might think up something else.

  • Theodora Profile Picture
    4 on at

    Hi @SwJ23 ,

    Thank you so much for your help!

    I tried the version using contains, and there is no error anymore (🎉!) however the query filters out my entire table and I have no data, so there must be a problem in finding the month and year in the date.

    I assumed that if I kept the ISO format 'yyyy-MM' it would work because the date format of the list rows from table is ISO.

    Theodora_0-1687428545231.png

    When it didn't work I adapted the format of my variable to the format of my Excel column ( 'MM/yyyy')

    Here is my due date column, it is a Date format here it is a French format but I tried first with the US format (6/23/2023).

     

    Theodora_0-1687420799428.png

    My real Excel table will be generated with Power BI so I guess I could give it any format I want.

     

    I think that I will have to add the reminder column to the original table, because I know it works and I thought using a more precise filter query would be easier than this, but I really don't have enough knowledge in Power Automate to do it 😅

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

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard