I have an Excel table with dates (column called "endDate"), and I want to know which dates are on the current week. For that I'm using the following OData filter query:
(endDate ge startOfWeek) and (endDate lt startOfNextWeek)
where startOfWeek is the following piece of dynamic content:
subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), "Day")
and startOfNextWeek is pretty similar, but adding 7 days to mark the start of the next week:
addDays(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), "Day"), 7)
The problem I'm getting is with subtractFromTime. If I add the "Day" parameter, I will get the error "The expression is invalid". If I don't include that parameter, I won't get that error but the flow won't run because subtractFromTime is lacking a parameter.
Is it a problem with Power Automate? Is there a problem with my filter I'm not seeing?
Thanks in advance
Its a very simple fix. You overlooked that you are writing the formula as JSON so it needs to use 'Day' not "Day". Change the double quotes to single quotes and it will work. I missed it myself for a few minutes.
addDays(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), 'Day'), 7)
Thanks for your response, this in fact seems to be the problem. But now it has raised 2 more issues, maybe you could know something about them.
Issue #1: Changed "Days" to 'Days', tried to save and got the same error ("The expression is invalid"). After that I did nothing and tried to save the expression again and worked just fine. Why is that?
Issue #2: When I tried to update the other "Day" to 'Day' (because I have 2 in my filter) it didn't show the error the first one had showed, but after saving I checked it and it hadn't really updated, it just saved as the old version ("Day" instead of 'Day'). I updated it again and it worked just fine. Are these normal bugs when working with Power Automate?
With error checking the update function can be a bit quirky at times. But I have no specific explanation other than that. I do know that you have to use the single quote instead of the double quote. I catch myself doing it inadvertently all the time.
Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.
Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.
The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.