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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jasprice
Regular Visitor

Use PREVIOUSYEAR function on a column that only contains a Year value

Hello,

 

I am trying to create a "Previous Year" measure using the PREVIOUSYEAR function but get the following error since my 'Fiscal Year' column is actually a Text data type. 

 

"A column specified in the call to function 'PREVIOUSYEAR' is not of type DATE. This is not supported."

 

Is there a work around for this?   Possibly creating a fake date format for the 'Fiscal Year' column?

 

Thanks.

1 ACCEPTED SOLUTION
KHorseman
Community Champion
Community Champion

All time intelligence functions require the use of an additional date table that contains an unbroken non-repeating series of dates covering the period required by your data. This table should have a relationship to a matching date column in your fact table. In the case of your monthly data perhaps a column with the end date of the month in question.





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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @jasprice,

 

From the prompt error, we can know that PREVIOUSYEAR function only support date type values. So, why don't you change the data type for that column in PowerBI. How is your 'Fiscal Year' column look like?

 

Also, as KHorseman mentioned, you need an additional date table, having a relationship to a matching date column in your fact table. 

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Yuliana,

 

I created a Date table lookup and joined it with my main (fact) table.   When I created the calculated measure it seems to be fine except when I add it to a Pivot Table.   When I do so it is blank.   Any idea why that would be?

 

This is the formula:

 

Previous Year Fees:=CALCULATE(SUM([Fees]),PREVIOUSYEAR(DimDate[Date]))

 

Jason

Nevermind, found my error.  I wasn't using the DimDate{Date) in my Pivot Table.  Was using the date in the "fact" table.

KHorseman
Community Champion
Community Champion

All time intelligence functions require the use of an additional date table that contains an unbroken non-repeating series of dates covering the period required by your data. This table should have a relationship to a matching date column in your fact table. In the case of your monthly data perhaps a column with the end date of the month in question.





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

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors