Error - Unknown Identifier in Advanced editor

Vinod V 1 Reputation point
2021-11-25T09:51:11.227+00:00

Hello All,

In Power BI Advanced editor I want a variable date that gets the Previous Month Last Date. (Eg In November it will give me October 31)

The code I am using is
{Cube.ApplyParameter, "IP_KEY_DATE", {Date.EndOfMonth(Date.AddMonths([Today],-1))}},

I do not get any syntax error but when it saves and loads I get the below error.

****Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?****

Please let me know how to resolve this.

Community Center Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ehren (MSFT) 1,781 Reputation points Microsoft Employee
    2021-12-08T00:36:15.937+00:00

    The problem is with [Today]. Try using DateTime.LocalNow() instead.

    Note that this will return the current date in UTC when run in the PBI service. (There are ways to deal with this, but just wanted you to be aware.)

    Also, Power Query is no longer supported here on Q&A. Going forward, please post your PQ questions at https://aka.ms/PQCommunity.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.