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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

0

Bug on year format

Here is an strange behaviour I've found out when using the following expresion:

 

 

 

year=YEAR(TODAY())

 

 

 

I get the correct value: 2023.

 

The issue is I need to calculate previous year, so when I go for this:

 

 

 

previousyear = FORMAT(YEAR(TODAY())-1,"yyyy")

 

 

 

the result is 1905

 

This is needed to compare between Fiscal years (the actual formula is more complex, but the issue stems from here) so I cant hardcode the year, as that would mean I have to rewrite a big ammount of the formluas after each FY

 

Status: Delivered
Comments
MattX
Frequent Visitor

Hello @ilopezgo ,

 

Try: 

 

year = YEAR(NOW()) - 1
 
Shows 2022 when I do this
ilopezgo
Regular Visitor

Thanks for the suggestion but the issue remains. The problem apparently is not related to the year itself but the formatting so both Year(Today()) and Year(now()) work propperly, the issue comes when going trying to format it into "yyyy" or "yy"

 

I need to format it as the Fiscal year information is stored in the two digits format, eg. FY22/23, thats why I need to format it. Sorry if this point wasnt clear enough in my first post.

Anonymous
Not applicable

Hi @ilopezgo 

When you use FORMAT with "YYYY" or "YY" ,  the <value> must be in date format . For example :

Ailsamsft_0-1673403481149.pngAilsamsft_1-1673403496605.png

So you need create a formula to return the previous year's date .

Measure 2 = FORMAT(DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())),"YYYY")

Ailsamsft_2-1673403720412.png

 

Best Regards,
Community Support Team _ Ailsa Tao

 

 

ilopezgo
Regular Visitor

This works!!

 

Thanks!!