Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good day!
Can you help me with interpretation of code another person in words:
If (Match(isNull([Fruits]), '1'), NULL(), isNull([Fruits)) AS [Orange1],
if ((If (Match(isNull([Fruits]), '1'), NULL(), isNull(Fruits])))=(-1),1,[Fruits])
What doas it mean in words? I don't understand
It's kind of weird nonsense code. I mean, maybe it works, but the logic is super weird. Feels like they were getting something to work via trial and error.
The first line says,
"Check if [Fruits] is null. This check gives out a number, and if that check resolves to '1', then return an actual null() value. If the result of checking for null doesn't resolve to a '1', then check if [Fruits] is null, and return that value and then call this field [Orange1]".
This is weird / nonsense for a few reasons. Firstly, isNull() returns a -1 (true) if something is null. Not a '1' (which is also quoted here, a boolean true or false doesn't use the quotes). So, the first part will never 'work'.
Second thing that's weird is doing a check of the result of isNull with Match in the first place. If you just do
"if(IsNull(Value), Null() )"
or even
"if(IsNull(Value), Value )"
You'd get the result you wanted here.
The next thing that's weird is that, this is exactly what it does for the second half, so why is it doing the odd match thing in the first place?
What this currently does is try and match something that will never match, so the first half will never happen. Then it checks if fruits is null and returns that value. So [Orange1] will just contain -1 if Fruits is null, and 0 if it isn't.
The second line basically just checks what the result of the first line is with an IF, and if it returns a -1 (a true value, because it found a null) then it changes the value from a -1 to a 1, otherwise it leaves it as the value in Fruits. It doesn't actually set this to a field though, I guess you've chopped off an AS [Fieldname].
So you'll get all of the Fruits values, but when they're null, now you'll get a 1 instead.
You could do all of this with:
If(isnull(Fruits),1,Fruits) AS [NewFieldName]