Forum Discussion
Help with creating column based on month
Hi,
I am getting the below error: (see screenshot)
Hi SJHALANI,
You haven't copied the code into a new blank query but in a step...
Create a new blank query, open the advanced editor window, select all you see there and replace it with the supplied code.
If you want to implement this code into your own query, here are the steps.
Select your query, open the advanced editor window, place your cursor after the in-clause, enter to go to a new line and paste in this code:
lookIn = {{"No", "No Funds"}, {"OK", "Sufficient Funds"}, {"One", -1}, {"Two", 0}, {"Three", 1}},
Now select the in-clause and all that follows and copy this in its place:
AddColumn = Table.AddColumn( Source, "NewColumn", each
let v = List.Select( lookIn, (x)=> x{0} = Text.BeforeDelimiter([PO Projections], " " )){0}{1} in
try Date.ToText( Date.AddMonths( Date.From( DateTime.FixedLocalNow()), v), [Format = "MMM yy", Culture="en-US"] )
otherwise v, type text
)
in
AddColumn
Where it says "Source" on this line: AddColumn = Table.AddColumn( Source
Replace that with the previous step name, just copy it from before the equals sign
Double check that your table includes a column with this name: [PO Projections]
and that should be it.
Ps. If this helps solve your query please mark this post as Solution, thanks!