Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
10 years ago
Solved

Change default fiscal year

Hi,   I am working on a July - June Fiscal year. I have a date column. I tried using the native Fiscal year transformation on this date to get the FY, but I do not see a way to change the FY from t...
  • greggyb's avatar
    10 years ago

    I'm curious what native fiscal year transformation you're referring to. I'm not aware of that in Power Query or DAX.

     

    That being said, it's trivial to add a fiscal year field in Power Query as a custom field:

     

    FiscalYear =
    let
      CYear = Date.Year( [Date] )
      ,FYear =
        if Date.Month( [Date] ) > 6
        then CYear + 1
        else CYear
    in
      FYear

    let simply defined a local namespace for us to work in.

     

    We assign CYear to the value of the calendar year for the date on the current row we're working on. This is only to avoid repetition of the function (which just leads to line noise). Then we assign FYear to the result of the if statement - if the (calendar) month number is > 6, then we know it belongs in the fiscal year that is 1 greater than the calendar year, else it's the same as the calendar year.

     

    Out of our let-statement namespace, we return the value of FYear.