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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
thrillhouse
Helper I
Helper I

Parameterize Fiscal Year

Hello,

 

I have been attempting to parameterize the fiscal year month start, but have had no luck.  I am building a calendar table that  determines the fiscal year as below.  What I want to do is in 'VAR FiscalStartMonth = 8', add a parameter value in place of 8 so the use can select the fiscal start month.  This does not seem to work as I get the following error "The optional argument of CALENDARAUTO function must be an integer between 1 and 12 inclusive."  

 

So the calendarauto function is not accepting the selected parameter value (1-12) as an integer.  Any thoughts or help on this would be greatly appreciated!  Thanks.

 

Fiscal Calendar =
VAR WeekStartsOn = "Mon"

VAR FiscalStartMonth = 8

RETURN

ADDCOLUMNS (

CALENDARAUTO( FiscalStartMonth - 1 ),

"MIndex", MONTH ( [Date] ),

"FiscalMIndex", MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ),

"CalMonth", FORMAT ( [Date], "mmm" ),

"CalQtr", "Q"

& CEILING ( MONTH ( [Date] ), FiscalStartMonth - 1 ) / ( FiscalStartMonth - 1 ),

"CalYear", YEAR ( [Date] ),

"Fiscal Week",

VAR FiscalFirstDay =

IF (

MONTH ( [Date] ) < FiscalStartMonth,

DATE ( YEAR ( [Date] ) - 1, FiscalStartMonth, 1 ),

DATE ( YEAR ( [Date] ), FiscalStartMonth, 1 )

)

VAR FilteredTableCount =

COUNTROWS (

FILTER (

SELECTCOLUMNS ( GENERATESERIES ( FiscalFirstDay, [Date] ), "Dates", [Value] ),

FORMAT ( [Dates], "ddd" ) = WeekStartsOn

)

)

VAR WeekNos =

IF (

FORMAT ( FiscalFirstDay, "ddd" ) <> WeekStartsOn,

FilteredTableCount + 1,

FilteredTableCount

)

RETURN

"Week " & WeekNos,

"Fiscal Qtr", "Q"

& CEILING ( MONTH ( EDATE ( [Date], - FiscalStartMonth + 1 ) ), 3 ) / 3,

"Fiscal Year",

VAR CY =

RIGHT ( YEAR ( [Date] ), 2 )

VAR NY =

RIGHT ( YEAR ( [Date] ) + 1, 2 )

VAR PY =

RIGHT ( YEAR ( [Date] ) - 1, 2 )

VAR FinYear =

IF ( MONTH ( [Date] ) > ( FiscalStartMonth - 1 ), "FY " & NY, "FY " & CY )

RETURN

FinYear,

"CalWeekNo", WEEKNUM ( [Date], 2 ),

"Weekend/Working", IF ( WEEKDAY ( [Date], 2 ) > 5, "Weekend", "Working" ),

"Day", FORMAT ( [Date], "ddd" ),

"CustomDate", FORMAT ( [Date], "d/mm" )
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @thrillhouse 

Thanks for reaching out to us.

>>I get the following error "The optional argument of CALENDARAUTO function must be an integer between 1 and 12 inclusive."  

Do not use addcolumns() to create a table.  Addcolumns() will add calculated columns to the given table or table expressionADDCOLUMNS function (DAX) - DAX | Microsoft Docs

vxiaotang_0-1656299945170.png

Just try to use calendarauto() to create a table firstly, then add other columns to it

vxiaotang_0-1656308942653.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xiaotang
Community Support
Community Support

Hi @thrillhouse 

Thanks for reaching out to us.

>>I get the following error "The optional argument of CALENDARAUTO function must be an integer between 1 and 12 inclusive."  

Do not use addcolumns() to create a table.  Addcolumns() will add calculated columns to the given table or table expressionADDCOLUMNS function (DAX) - DAX | Microsoft Docs

vxiaotang_0-1656299945170.png

Just try to use calendarauto() to create a table firstly, then add other columns to it

vxiaotang_0-1656308942653.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.