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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
TRK
Helper II
Helper II

Create Fiscal Year Offset calculation in Power Query Custom Date Table

Hi,

 

I have a custom calendar created in Power Query - M.  

I want to be able to flag the current FISCAL year  (my fiscal runs April 1 - March 31st) - so I need to be able to calculate the Fiscal Year Offset to do that.

See Query table extract below: (note:  I simplified this table to export here - the date column actually has every day in the month (not just the first day)) 

I was able to create a columns to calculate "Current Year offset" and then from that I can flag the current year as the value is 0.

 

I also have Fiscal month # column, Fiscal quarter, etc.  But I want to be able to flag the current FISCAL year  (my fiscal runs April 1 - March 31st)
The code in custom columns I have already that are working as expected:

 

FiscalYearEndMonth = 3   

 

 "FiscalMonthNum"

 if [MonthNum] > FiscalYearEndMonth  then [MonthNum] - FiscalYearEndMonth  else [MonthNum] + (12 - FiscalYearEndMonth)

 

 "CurYearOffset"

 Date.Year([Date]) - Date.Year(CurrentDate)

 "Flag Current Calendar Year" (cond. Column)

 if [CurYearOffset] = 0 then "Current Year" else null

DateFiscalMonthNumFiscal YearCurMonthOffsetCurYearOffsetFlag Current Calendar YearWhat I want: Offset FYWhat I want:    FY Flag
2021-04-0112021-2022-11-1null0Current FY
2021-05-0122021-2022-10-1null0Current FY
2021-06-0132021-2022-9-1null0Current FY
2021-07-0142021-2022-8-1null0Current FY
2021-08-0152021-2022-7-1null0Current FY
2021-09-0162021-2022-6-1null0Current FY
2021-10-0172021-2022-5-1null0Current FY
2021-11-0182021-2022-4-1null0Current FY
2021-12-0192021-2022-3-1null0Current FY
2022-01-01102021-2022-20Current Year0Current FY
2022-02-01112021-2022-10Current Year0Current FY
2022-03-01122021-202200Current Year0Current FY
2022-04-0112022-202310Current Year1 
2022-05-0122022-202320Current Year1 
2022-06-0132022-202330Current Year1 
2022-07-0142022-202340Current Year1 
2022-08-0152022-202350Current Year1 
2022-09-0162022-202360Current Year1 
2022-10-0172022-202370Current Year1 
2022-11-0182022-202380Current Year1 
2022-12-0192022-202390Current Year1 
2023-01-01102022-2023101null1 
2023-02-01112022-2023111null1 
2023-03-01122022-2023121null1 



Any help would be appreciated.

1 ACCEPTED SOLUTION
TRK
Helper II
Helper II

I found a solution.  

I created the following 3 columns:
FY End Year:  (provides the end year of the fiscal year)

= Table.AddColumn(#"Added FY End", "FY Year", each if [MonthNum] > FiscalYearEndMonth
then [Year] + 1 else [Year])

Year.Now
step 1:  (fills column with current date & time now - all same value)

= Table.AddColumn(#"FY End Year", "Year.Now", each DateTime.LocalNow())
step 2:  (extract year from this column using transform tab in ribbon: button 'Date' and selecting 'year' - to just have dynamic current year) 

= Table.TransformColumns(#"Date.Now (Year.Now)",{{"Year.Now", Date.Year, Int64.Type}})

 

Current FY Offset (The current fiscal year will have 0's)
= Table.AddColumn(#"Extracted Year", "Current FY Offset", each [FY End Year-[Year.Now])

View solution in original post

3 REPLIES 3
TRK
Helper II
Helper II

I found a solution.  

I created the following 3 columns:
FY End Year:  (provides the end year of the fiscal year)

= Table.AddColumn(#"Added FY End", "FY Year", each if [MonthNum] > FiscalYearEndMonth
then [Year] + 1 else [Year])

Year.Now
step 1:  (fills column with current date & time now - all same value)

= Table.AddColumn(#"FY End Year", "Year.Now", each DateTime.LocalNow())
step 2:  (extract year from this column using transform tab in ribbon: button 'Date' and selecting 'year' - to just have dynamic current year) 

= Table.TransformColumns(#"Date.Now (Year.Now)",{{"Year.Now", Date.Year, Int64.Type}})

 

Current FY Offset (The current fiscal year will have 0's)
= Table.AddColumn(#"Extracted Year", "Current FY Offset", each [FY End Year-[Year.Now])

amitchandak
Super User
Super User

@TRK , Try a new column like

 


if [Date] >= #date(if Date.Month(Date.From(DateTime.FixedLocalNow())) >3 Then Date.Year(Date.From(DateTime.FixedLocalNow()))-1 else Date.Year(Date.From(DateTime.FixedLocalNow())),4,1) && [Date] >= #date(if Date.Month(Date.From(DateTime.FixedLocalNow())) >3 Then Date.Year(Date.From(DateTime.FixedLocalNow())) else Date.Year(Date.From(DateTime.FixedLocalNow()))+1 ,3,31) then 1 else 0

That doesn't seem to work.  I fixed the 2 Then to then and it didn't accept && so I change that to and  but everything in the column returned 0

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.