Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Unknowncharacte
Helper III
Helper III

Custom Column - Current Fiscal Year

Hello, 

 

I am trying to identify current FISCAL year. My fiscal year starts on October 1st and ends on September 30th, for example:

Calendar DateFiscal Year
09/29/20242024
09/30/20242024
10/01/20242025
10/02/20242025

 

I have a calendar table in which I want to add a column identifying current FISCAL year, here are my columns

Calendar DateCalendar YearFiscal YearMonth NameMonth Number
10/01/202420242025October10

 

I was able to identify current CALENDAR year by creating a custom colum with this syntax:

 

if Date.Year(DateTime.LocalNow()) = [Calendar Year]

then "Current Year"

else "FY"&Number.ToText([Calendar Year]) 

However, I cannot figure out how to achive the same but for the FISCAL Year, it just doesn't compute in my mind. Can anyone help please?

2 ACCEPTED SOLUTIONS
AlanFredes
Resolver IV
Resolver IV

Hi @Unknowncharacte 

 

This if statement in a custom column should be able to give you what you want.

The logic tries to identify if you are within the month range and within the Current Fiscal Year.

if Date.Month([Calendar Date])>=10 and Date.Month([Calendar Date])<=12 and [Fiscal Year] = Date.Year(DateTime.LocalNow())+1 then "Y"
else if Date.Month([Calendar Date])>=1 and Date.Month([Calendar Date])<=9 and [Fiscal Year] = Date.Year(DateTime.LocalNow()) then "Y"
else "N"

 

Regards,
Alan Fredes

Did I answer your question? Mark my post as a solution!

View solution in original post

v-xinruzhu-msft
Community Support
Community Support

Hi,

Thanks for the solution @AlanFredes  provided, and i want to offer some more infotmation for user to refer to.

hello @Unknowncharacte , you can create a the following custom column.

=let
  currentdate = DateTime.Date(DateTime.LocalNow()), 
  currentyear = Date.Year(currentdate), 
  lastyear = currentyear - 1, 
  nextyear = currentyear + 1, 
  currentFY = 
    if currentdate >= #date(lastyear, 10, 1) and currentdate <= #date(currentyear, 9, 30) then
      currentyear
    else if currentdate >= #date(currentyear, 10, 1) and currentdate <= #date(nextyear, 9, 30) then
      nextyear
    else
      0
in
  if [Fiscal Year] = currentFY then "Current Fiscal Year" else "FY" & Number.ToText([Fiscal Year])

vxinruzhumsft_0-1720678166481.png

 

vxinruzhumsft_1-1720678179996.png

And you can refer to the following m code.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrDUNwIiAyMTJR0lZCpWByxpbIBL0tBA38AQU9IULmmEVTIWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Calendar Date" = _t, #"Calendar Year" = _t, #"Fiscal Year" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Calendar Date", type date}, {"Calendar Year", Int64.Type}, {"Fiscal Year", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Current Fiscal Year", each let
  currentdate = DateTime.Date(DateTime.LocalNow()), 
  currentyear = Date.Year(currentdate), 
  lastyear = currentyear - 1, 
  nextyear = currentyear + 1, 
  currentFY = 
    if currentdate >= #date(lastyear, 10, 1) and currentdate <= #date(currentyear, 9, 30) then
      currentyear
    else if currentdate >= #date(currentyear, 10, 1) and currentdate <= #date(nextyear, 9, 30) then
      nextyear
    else
      0
in
  if [Fiscal Year] = currentFY then "Current Fiscal Year" else "FY" & Number.ToText([Fiscal Year]))
in
    #"Added Custom"

 

Output

 

 

View solution in original post

3 REPLIES 3
v-xinruzhu-msft
Community Support
Community Support

Hi,

Thanks for the solution @AlanFredes  provided, and i want to offer some more infotmation for user to refer to.

hello @Unknowncharacte , you can create a the following custom column.

=let
  currentdate = DateTime.Date(DateTime.LocalNow()), 
  currentyear = Date.Year(currentdate), 
  lastyear = currentyear - 1, 
  nextyear = currentyear + 1, 
  currentFY = 
    if currentdate >= #date(lastyear, 10, 1) and currentdate <= #date(currentyear, 9, 30) then
      currentyear
    else if currentdate >= #date(currentyear, 10, 1) and currentdate <= #date(nextyear, 9, 30) then
      nextyear
    else
      0
in
  if [Fiscal Year] = currentFY then "Current Fiscal Year" else "FY" & Number.ToText([Fiscal Year])

vxinruzhumsft_0-1720678166481.png

 

vxinruzhumsft_1-1720678179996.png

And you can refer to the following m code.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrDUNwIiAyMTJR0lZCpWByxpbIBL0tBA38AQU9IULmmEVTIWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Calendar Date" = _t, #"Calendar Year" = _t, #"Fiscal Year" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Calendar Date", type date}, {"Calendar Year", Int64.Type}, {"Fiscal Year", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Current Fiscal Year", each let
  currentdate = DateTime.Date(DateTime.LocalNow()), 
  currentyear = Date.Year(currentdate), 
  lastyear = currentyear - 1, 
  nextyear = currentyear + 1, 
  currentFY = 
    if currentdate >= #date(lastyear, 10, 1) and currentdate <= #date(currentyear, 9, 30) then
      currentyear
    else if currentdate >= #date(currentyear, 10, 1) and currentdate <= #date(nextyear, 9, 30) then
      nextyear
    else
      0
in
  if [Fiscal Year] = currentFY then "Current Fiscal Year" else "FY" & Number.ToText([Fiscal Year]))
in
    #"Added Custom"

 

Output

 

 

Thank you, and if I need to adjust this to last fiscal year, do I just change "lastyear = currentyear - 2"?

=let

  currentdate = DateTime.Date(DateTime.LocalNow()),

  currentyear = Date.Year(currentdate),

  lastyear = currentyear - 2,

  nextyear = currentyear + 1,

  currentFY =

    if currentdate >= #date(lastyear, 10, 1) and currentdate <= #date(currentyear, 9, 30) then

      currentyear

    else if currentdate >= #date(currentyear, 10, 1) and currentdate <= #date(nextyear, 9, 30) then

      nextyear

    else

      0

in

  if [Fiscal Year] = currentFY then "Current Fiscal Year" else "FY" & Number.ToText([Fiscal Year])

AlanFredes
Resolver IV
Resolver IV

Hi @Unknowncharacte 

 

This if statement in a custom column should be able to give you what you want.

The logic tries to identify if you are within the month range and within the Current Fiscal Year.

if Date.Month([Calendar Date])>=10 and Date.Month([Calendar Date])<=12 and [Fiscal Year] = Date.Year(DateTime.LocalNow())+1 then "Y"
else if Date.Month([Calendar Date])>=1 and Date.Month([Calendar Date])<=9 and [Fiscal Year] = Date.Year(DateTime.LocalNow()) then "Y"
else "N"

 

Regards,
Alan Fredes

Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.