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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Previous Year not working

Hi,

I am running a previous year measure with 

 

Sales Prev Year = CALCULATE(SUM('Chalgrove FactSalesOrderLine'[SaleValueBase]),PREVIOUSYEAR(DimDate[FullDate].[Year]))
 
However I am getting the following error
 

Calculation error in measure 'Chalgrove FactSalesOrder'[Sales Prev Year]: A column specified in the call to function 'PREVIOUSYEAR' is not of type DATE. This is not supported.

 

The fulldate column is a date type..

 

Zoomfs_0-1624444186968.png

 

Can anyone help?

 

Thanks

 

Chris

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Sales Prev Year =
CALCULATE(
    SUM( 'Chalgrove FactSalesOrderLine'[SaleValueBase] ),
    PREVIOUSYEAR( DimDate[FullDate] )
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

7 REPLIES 7
CNENFRNL
Community Champion
Community Champion

Sales Prev Year =
CALCULATE(
    SUM( 'Chalgrove FactSalesOrderLine'[SaleValueBase] ),
    PREVIOUSYEAR( DimDate[FullDate] )
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

It is not failing now.. however it is not returning any values.

 

 

 

 

No surprise; any measure evalutes in a comprehensive evaluation context. I helped correct syntactic error of DAX; analyse and author measures for desired results by yourself.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Lol thanks for the help.. at least its not failing now .. much appreciated.

ERD
Super User
Super User

Hi @Anonymous ,

Check that DimDate[FullDate] is of Date type and try 

Sales Prev Year = CALCULATE(SUM('Chalgrove FactSalesOrderLine'[SaleValueBase]),PREVIOUSYEAR(DimDate[FullDate]))

See https://dax.guide/previousyear/ 

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

amitchandak
Super User
Super User

@Anonymous ,Please mark this table as date tbale DimDate, also check data type of join column  in FactSalesOrder, that should also be date column

 

if not

Can you share a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Hi @amitchandak 

 

I am unable to make it a dat table as there is missing dates. our system puts defasult dates starting at 1900 so we need to have that in there along with the other info.

 

Thanks

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.