Search code examples
google-sheetsgoogle-sheets-formula

Trying to Color code Sparkline bar graph in Google sheets but getting unexpected errors


I am color coding my sparklines bar graph based on percentage cutoffs and get formula parse errors.This gets an error

=SPARKLINE((E6/F6),{"charttype","bar";"max",1; "min",0;color1",IF((E6/F6)>0.9,"blue",IF((E6/F6)>0.7,"green",IF((E6/F6)>0.5,"yellow","red"))})

while this works.

=SPARKLINE((E6/F6),{"charttype","bar";"max",1; "min",0;color1",IF((E6/F6)>0.9,"blue",IF((E6/F6)>0.7,"green","yellow"))})

The only difference I spot is how many IFs I have. Is there some limit to the number of ifs you can nest or am I missing something else?

I have tried starting from the beginning and adding one IF at a time but when I reach a certain point it just stops working


Solution

  • There seems to be slight mismatch with the if() closing brackets:

    =SPARKLINE((E6/F6),{"charttype","bar";"max",1; "min",0;"color1",IF((E6/F6)>0.9,"blue",IF((E6/F6)>0.7,"green",IF((E6/F6)>0.5,"yellow","red")))})
    

    enter image description here