Forum Discussion
Fiscal year in format 2023-24 for example
Hi there, I created a date table in power query and have created a fiscal year column, but it says 2023, rather than 2023-24, for example. Does anyone have M code I could try to get it in the correct format? I have added a screenshot of my date table
5 Replies
- amitchandak
Super User
Lizzieleman , Create a new column like
If( Date.Month([Date]) <=3 , Number.ToText(Date.Year([Date])) & "-" & Text.End(Number.ToText(Date.Year([Date])+1),2) , Number.ToText(Date.Year([Date])+1) & "-" & Text.End(Number.ToText(Date.Year([Date])+2),2) )
- LizzielemanFrequent Visitor
I get an error
"Expression.Error: The name 'If' wasnt recognised. Make sure it is spelled correctly.
I changed it to= Table.AddColumn(#"Changed Type", "Custom", each if (Date.Month([Date]) <=3 , Number.ToText(Date.Year([Date])) & "-" & Text.End(Number.ToText(Date.Year([Date])+1),2)) , Number.ToText(Date.Year([Date])+1) & "-" & Text.End(Number.ToText(Date.Year([Date])+2),2)
and now it says Expression.SyntaxError: Token ')' expected.
But I can't figure out where that ) would go- AnonymousNot applicable
Hi Lizzieleman ,
In the code you provided:
There are 13 "(" and only 12 ")". You need to add a ")" at the end of the code.
And remember to accept amitchandak 's answer as a solution.
Best Regards,
Dino Tao- LizzielemanFrequent Visitor
Yes I tried this it still has the same error
Code now reads like this:
if( Date.Month([Date]) <=3 , Number.ToText(Date.Year([Date])) & "-" & Text.End(Number.ToText(Date.Year([Date])+1),2) , Number.ToText(Date.Year([Date])+1) & "-" & Text.End(Number.ToText(Date.Year([Date])+2),2)))
But doesn't work