Forum Discussion
gvg
4 years agoPost Prodigy
We cannot convert the value null to type Number
Hi, I know there is a number of threads with this title, however none of them provide clear answer. At least for my case. I am getting this message when trying to sort a column with integer values....
Anonymous
4 years agoNot applicable
The error is actually being caused by this part of your if statement:
[Sales history months] = null
PQ is saying "null is never equal to any number, so why am I comparing it to a number?"
Instead, write it as:
#"Replaced Value" = Table.ReplaceValue(ChangedType3,each _, each if Number.IsNaN([Sales history months]) or [Sales history months] is null then 24 else [Sales history months],Replacer.ReplaceValue,{"Sales history months"}),
- gvg4 years agoPost Prodigy
What's wrong with the comparison using "=" to null? PQ does not complain about it.
- ImkeF4 years agoCommunity Champion
Hi gvg ,
this error is triggered by theNumber.IsNaN([Sales history months])in your first step.
Null cannot be converted to a number an this triggers the error.
To overcome this you can wrap that statement in a try-otherwise error-handler:try Number.IsNaN([Sales history months]) otherwise true