Change Data Type with Dax

Good day team,

Hoping you can help me with an issue. I am trying to calculate Datedif between last sale date and today. My issue come in where the saledateid data type is whole number and i unfortunately cannot change it because of access restrictions.

is there a way to convert the data type via dax or create a new measure with the correct data type?

i created the datedif dax but it throws out an error which i presume is because the data type is difference from the “today” formula

Hi @neilonbooysen,

Give something like this a go to change the latest date number into a date datatype. Note that I am assuming the integer is always: YYYYMMDD as shown in your image.

Date from TXT =
VAR v = CONVERT( MAX( 'Table'[Latest date] ), STRING )
VAR Y = LEFT( v, 4 )*1
VAR M = MID( v, 5, 2 )*1
VAR D = RIGHT( v, 2) *1
RETURN

DATE( Y, M, D )
1 Like

Thanks @Melissa , life saver.

This works prefectly.

Regards
Neilon