Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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..

 

 

Can anyone help?

 

Thanks

 

Chris

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

7 Replies

  • ERD's avatar
    ERD
    Icon for Community Champion rankCommunity Champion

    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.

  • 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.

    • Anonymous's avatar
      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

  • CNENFRNL's avatar
    CNENFRNL
    Icon for Community Champion rankCommunity Champion
    Sales Prev Year =
    CALCULATE(
        SUM( 'Chalgrove FactSalesOrderLine'[SaleValueBase] ),
        PREVIOUSYEAR( DimDate[FullDate] )
    )
    • Anonymous's avatar
      Anonymous
      Not applicable

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

       

       

       

       

      • CNENFRNL's avatar
        CNENFRNL
        Icon for Community Champion rankCommunity Champion

        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.