Forum Discussion
Anonymous
2 years agoNot applicable
Reporting constant errors:variant data-type cannot be used to define calculated columns
Hi,
I have a table named: FACT_Stock, I want to create a calculated column to define remaining shelf life (months).
Mine methodology is to use Column [EXP], [PictureDate], these two colum type is date, [EXP] is mixed with some blanks.
Formula of Remaining shelf life (months) is written as
[RSL] =
VAR Months = IF(FACT_Stock[EXP] = BLANK(), BLANK(), DATEDIFF(FACT_Stock[PictureDate],FACT_Stock[EXP],MONTH))
RETURN
IF(
Months = BLANK(),
"Undefined",
SWITCH(
TRUE(),
Months <= 0,
"Expired",
Months >= 48,
"Not relevant",
Months
)
)
It keeps reporting errors: Expressions that yield variant data-type cannot be used to define calculated columns. I tried serveral ways to fix the error, such as use CONVERT formula to transform data type, but the error doesn't diappear
2 Replies
- PhilipTreacySuper User
Hi Anonymous
Plese supply a representataive sample of your data (or all of it), so we can see what your working with. Really hard to debug something without seeing the data.
Regards
Phil
- AnonymousNot applicable
Hi Philip,
Table is like this wayItemCode EXP SOH PictureDate H084490001 2021/11/14 70 2024/3/31 H084560001 2022/5/14 60 2024/3/31 H084560001 2022/3/14 13 2024/3/31 H084560001 2022/5/14 40 2024/3/31 H084560001 2999/12/31 10 2024/3/31 H084580001 2022/4/14 60 2024/3/31 H084580001 2022/6/14 14 2024/3/31 H084580001 2022/6/14 6 2024/3/31 H084580001 2023/4/18 50 2024/3/31 H084580001 2022/6/14 15 2024/3/31 CBLM250 19 2024/3/31 CBLM250 36 2024/3/31 CBLM250T 1 2024/3/31 CBLM250T 7 2024/3/31 50551 2026/12/20 439 2024/3/31 49831 2026/7/18 3829 2024/3/31 49831 2026/7/18 5 2024/3/31 50551 2026/6/21 15722 2024/3/31 49831 2026/3/31 1 2024/3/31 50941 2026/3/30 496 2024/3/31 CL20811T 34 2024/3/31 CL20811T 767 2024/3/31 CL20811TT 9 2024/3/31 H282030001 2099/1/1 12 2024/4/1 H282050001 2099/1/1 54 2024/4/1 H285010001 2099/1/1 15 2024/4/1 H328010001 2099/1/1 9875 2024/4/1