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! Request now

Reply
Mheadland
Frequent Visitor

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:

Mheadland_1-1701699282561.png

 

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 🙂

 

1 ACCEPTED SOLUTION

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] ) & ""
        )
    )
)

View solution in original post

11 REPLIES 11
Ahmedx
Super User
Super User

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

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. 

Mheadland_0-1701855788873.png

 

Thank you in advance

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.

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])))

pls try 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 ),
        FORMAT(TODAY ()-'00_StockData'[WSDate],"dd-MM-yyyy"),
        FORMAT( ( VALUE ( '00_StockData'[R date] ) - '00_StockData'[WSDate] ),"dd-MM-yyyy")
    )
)

 

pls try 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 ),
        FORMAT ( TODAY () - '00_StockData'[WSDate], "dd-MM-yyyy" ),
        FORMAT (
            ( VALUE ( '00_StockData'[R date] ) - '00_StockData'[WSDate] ),
            "dd-MM-yyyy"
        )
    )
)

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] ) & ""
        )
    )
)

This is the one 🙂 Thank you so much for all of your help!!

always happy to help

Ahmedx
Super User
Super User

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

Screenshot_8.png

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?

Mheadland_0-1701700860952.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors