I am facing some troubles in Vega Lite while trying to achieve the following: I want to extract the minimum value from three measures, which works fine until one of the measures is blank - then it takes NULL as the minimum value.
I would like the calculation to ignore NULL values and only evaluate it on measures that are not blank. So basically, when it is [10, 5, NULL], it should return 5 as the result instead of NULL.
How could I achieve this? I have tried incorporating the "filter" function, but it did not work out.
This is the line of code where I would like to apply this condition:
...{
"calculate": "min(datum['min_actual'], datum['min_base'], datum['min_base_minus_1'])",
"as": "low_value"
}...
Thanks a lot for your help!
You could test each value with a ternary operation and if null, return a large number.
Something like:
{
"calculate": "min(isValid(datum['min_actual'])?datum['min_actual']:9e20, isValid(datum['min_base'])?datum['min_base']:9e20, isValid(datum['min_base_1'])?datum['min_base_1']:9e20)",
"as": "low_value"
}