Forum Discussion

ZataConsulting's avatar
ZataConsulting
Regular Visitor
8 years ago
Solved

MdxScript(Model)(187,74).....Calulcation error in measure

I have use the followin formu;ar Total Revenue LY = Calculate([Total Revenue],SAMEPERIODLASTYEAR(DimDate[Date].[Year])) and get the following error message

 

 

 

Here is part of the error message: 'Calculated Measures'[Total Revenue LY]; A column specified in the call to function " SAMEPRIOD LASTYEAR" is not date type.  AM finding this difficult to understand. The Date COlumn is a date ctype. I have tried to use DATEADD , but I still get the same error. I have looked in most discussion , I have not found a solution. Can anyone help. 

  • Hi ZataConsulting,

     

    Please try again without the ".[Year]" part. 

     

    Total Revenue LY =
    CALCULATE ( [Total Revenue], SAMEPERIODLASTYEAR ( DimDate[Date].[Year] ) )
    

    Mdx_Script_Model

     

     

    Best Regards,

    Dale

3 Replies

  • Hi ZataConsulting,

     

    Please create a date table ( with continuous date) and link it to your "fact" table.

    Then you can use these formula to calculate previous period revenue.

     

    We can assist if you have any issues.

     

     

    Ninter

    • ZataConsulting's avatar
      ZataConsulting
      Regular Visitor
      Total Revenue LY =
      CALCULATE ( [Total Revenue], SAMEPERIODLASTYEAR ( DimDate[Date].[Year] ) )

        Thankyou. The solution works. 

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi ZataConsulting,

     

    Please try again without the ".[Year]" part. 

     

    Total Revenue LY =
    CALCULATE ( [Total Revenue], SAMEPERIODLASTYEAR ( DimDate[Date].[Year] ) )
    

    Mdx_Script_Model

     

     

    Best Regards,

    Dale