Forum Discussion

Mheadland's avatar
Mheadland
Frequent Visitor
2 years ago
Solved

Expressions that yield variant data-type cannot be used to define calculated columns ( with dates)

Hi all,

 

I am currently trying to create a column that states how long an item has been in stock, this is the formula I am using but I keep recieving the same error message:

 

I have tried to use other forum results to fix this such as: ensuring all column are the same data type (date), using a today column rather then the today() function, entering my filter as date() rather than just the date as dd/mm/yyyy, and a few others but nothing seems to be working.

 

Does anyone have any other suggestions?

 

Many thanks 🙂

 

  • or this

    DealerStockDays =
    IF (
        AND (
            '00_StockData'[R date] = DATE ( 2173, 10, 13 ),
            '00_StockData'[WSDate] = DATE ( 2173, 10, 13 )
        ),
        "-",
        IF (
            '00_StockData'[R date] = DATE ( 2173, 10, 13 ),
            ( TODAY () - '00_StockData'[WSDate] ) & "",
            (
                ( VALUE ( '00_StockData'[R date] ) - '00_StockData'[WSDate] ) & ""
            )
        )
    )

11 Replies

  • you need to add two quotes where the date is like this TODAY()&""
    you have the date in two places

    • Mheadland's avatar
      Mheadland
      Frequent Visitor

      Thank you for that sugesstion, it has fixed the error issue but rather than completing the calculation it just shows me the sum ( as seen in the far right column). Do you know how to fix this?

       

  • remove the quotes and use the functions FORMAT( TODAY(), "dd-MM-yyyy")

    • Mheadland's avatar
      Mheadland
      Frequent Visitor

      Apologies, I don't quite understand what you mean by this, is there any chance you could write it down for me so I can visualise what I need to add/remove. 

       

      Thank you in advance

      • Ahmedx's avatar
        Ahmedx
        Icon for Super User rankSuper User

        you copy the measure and paste it here.
        I can't copy it from a picture.
        after that I'll show you what I mean.