Stats normalize to 0 or 1, maybe conditional

Asked by Mario

We have a stat that we want to maintain saving it as it is (values from 0 to N) but for a graphic we want to transform this values to something boolean (0 or 1).

Is it possible use conditional rules or something like that?

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
Jason Dixon
Solved:
Last query:
Last reply:
Revision history for this message
Best Jason Dixon (jason-dixongroup) said :
#1

This is a bit of a hack, but you could do something like this:

transformNull(
    offset(
        scale(
            removeBelowValue(foo.bar,1)
        ,0)
    ,1)
,0)

I start by removing everything below the value of 1, converting them to nulls. You may need to adjust this to something like 0.0001 if you're storing decimal values less than 1.

I then zero the remaining values and increment them to 1 (our "true" values).

Lastly, I transform the null values back to 0 (our "false" values).

Revision history for this message
Mario (mariodefrutos) said :
#2

Thanks Jason Dixon, that solved my question.