Forum Discussion
lazzarjovvch74
Helper I
8 years agoCan't compare value of type integer
Hi,
I created the next measure but got an error saying that doesn't support comparing values of type integer with values of type Text.
Measure 1 = IF(HASONEVALUE('MyTable'[Year]), CALCULATE(AVERAGE('MyTable'Price]), 'MyTable'[Year] = FORMAT(VALUES('MyTable'[Year])-1,BLANK())))Just to emphasize that column Year is of type INTEGER. If I convert the column 'Year' to type Text, the above formula works, but I want to keep it as integer. Any idea how I can rewrite this formula?
Thanks
Silly me,
you have to rewrite your measure this way
Measure 1 = IF(HASONEVALUE('MyTable'[Year]), CALCULATE( AVERAGE('MyTable'[Price]) ,FILTER( ALL('MyTable'[Year]) ,'MyTable'[Year] = MAX('MyTable'[Year])-1 ) ) ,BLANK() )I'm sorry for my confusion.
Regards,
Tom
5 Replies
- TomMartens
Super User
Hey,
I'm wondering why you not just use this... 'MyTable'[Year] = 'MyTable'[Year]-1
Regards,
Tom- lazzarjovvch74
Helper I
Hi,
I tried that but an error appeared (red line under 'MyTable'[Year]):- TomMartens
Super User
Silly me,
you have to rewrite your measure this way
Measure 1 = IF(HASONEVALUE('MyTable'[Year]), CALCULATE( AVERAGE('MyTable'[Price]) ,FILTER( ALL('MyTable'[Year]) ,'MyTable'[Year] = MAX('MyTable'[Year])-1 ) ) ,BLANK() )I'm sorry for my confusion.
Regards,
Tom