Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

Filter issues

Posted on by 2

I have a flow that gets new responses from a MS Forms and transfers the answers into a master spreadsheet in team. The nest morning another flow goes into the master file and pull the responses from the last 24 hours. It works on day one but the following day it creates a new file with answers provided almost 2 days ago. I think the issue is that the filter does not include an "apply to each". I tried fixing it but now the filters does not work at all.

 

Original code:

@greater(formatDateTime(item()?['Completion time'], 'yyyy-MM-dd hh:mm:ss z'), addToTime(formatDateTime(utcNow(), 'yyyy-MM-dd hh:mm:ss z'), -28, 'Hour', 'yyyy-MM-dd hh:mm:ss z'))

 

New code (not working):

@greater(formatDateTime(item('Apply_to_each')?['Completion time'], 'yyyy-MM-dd hh:mm:ss z'), addToTime(formatDateTime(utcNow(), 'yyyy-MM-dd hh:mm:ss z'), -28, 'Hour', 'yyyy-MM-dd hh:mm:ss z'))

 

Error received:

InvalidTemplate. The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@greater(formatDateTime(item('Apply_to_each')?['Start time'], 'yyyy-MM-dd hh:mm:ss z'), addToTime(formatDateTime(utcNow(), 'yyyy-MM-dd hh:mm:ss z'), -28, 'Hour', 'yyyy-MM-dd hh:mm:ss z'))' failed: 'The template language function 'item' must not have any parameters.'.

 

 

  • Chriddle Profile Picture
    Chriddle 6,840 on at
    Re: Filter issues
    1. Usually datetimes returned by Power Automate actions are UTC. If you want to compare them with utcNow() there is no need to consider time zones.
    2. If you really have to, use function convertTimeZone() https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#convertTimeZone
    3. There is no need to use the formatDateTime() function in your above experssions since Power Automate actions and functions return ISO 8601 formated datetime strings.
    4. item('Apply_to_each') is not valid. Do you mean items('Apply_to_each')
  • coronj3 Profile Picture
    coronj3 2 on at
    Re: Filter issues

    I'm using -28 hours because the difference between UTS and Eastern, this gives me the 24 hours I need. As you can see here the flow ran at 9:0034am, the cut off of 24 hours should be  8/28/23 9:00am but the filter returned records from 8/27/23. This only happens only happens on the second day after the first filter returns all the correct records.

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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,651

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,727

Leaderboard

Featured topics