Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello,
I am attempting to use Power Query to do the following in plain langue: If a date appears at the beginning of the month, replace it with the last date of the previous month (essentially, push it back one day). Leave all other dates alone.
So far, I have deduced the following:
= if Date.Day([End Current]) = 1 then Table.ReplaceValue(#"Changed Type" ,each [End Current] ,each Date.AddDays([End Current], -1) ,Replacer.ReplaceValue,{"End Current"}) else [End Current]
But I am receiving the error "Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?"
And I can't trace it.
Anybody have an idea about how to resolve?
FYI: Date.Day function returns a numeric for the date referenced, and Date.AddDays adds or removes an integer number of days according to the argument given (in this case, -1).
What am I missing?
THANK YOU!
Solved! Go to Solution.
Can you please try this... Replacer.ReplaceValues may have some issues in conditional replace
#"OutP" =
Table.RenameColumns(
Table.RemoveColumns(
Table.AddColumn( #"Changed Type", "NewDate",
each if Date.Day([End Current]) = 1 then
Date.AddDays([End Current], -1) else [End Current]),
{"End Current"}),{{"NewDate", "End Current"}})
Can you please try this... Replacer.ReplaceValues may have some issues in conditional replace
#"OutP" =
Table.RenameColumns(
Table.RemoveColumns(
Table.AddColumn( #"Changed Type", "NewDate",
each if Date.Day([End Current]) = 1 then
Date.AddDays([End Current], -1) else [End Current]),
{"End Current"}),{{"NewDate", "End Current"}})
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
113 | |
81 | |
45 | |
42 | |
27 |
User | Count |
---|---|
182 | |
83 | |
70 | |
48 | |
45 |