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
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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.