Forum Discussion
function logical error
Hi, i kinda get why this error happens but thougt someone might have thoughts insights into the
error problem;
i i start with a true false ;
= let test =( x)=> Number.Round(x) = x
in test
but if i then us ;
if test then "whole" else "decimal"
i get an eroor but i can use ;
= (x)=> if Number.Round(x) = x then "whole" else "decimal"
sorry for the spacing , I could not get code tags to work and the formatting kept goiong all over the plaice.
Hi Dicken,
In Power query, functions themselves can't be used as a boolean value. Test is a function, not a boolean itself, so you need to call the function with a value for it to return something useful.
let
test = (x) => Number.Round(x) = x,
result = if test(5) then "whole" else "decimal"
in
result
2 Replies
- tayloramy
Super User
Hi Dicken,
In Power query, functions themselves can't be used as a boolean value. Test is a function, not a boolean itself, so you need to call the function with a value for it to return something useful.
let
test = (x) => Number.Round(x) = x,
result = if test(5) then "whole" else "decimal"
in
result - Dicken
Post Prodigy
yes, i did see why it failed after posting ,i was actually trying for a function that tests a a value
and continues various tests until a true is reached, this is a work in progress, but my first obstacle
, this one is now fixed.