使用SPARKLINES的SWITCH来给主条着色不同的颜色

问题描述 投票:0回答:2

我正在寻找基于其值更改迷你图的颜色或主色条的最佳方法。这是用于预算工作表的。我希望主栏在仍然低于年度预算时为蓝色,在恰好是年度预算时为绿色,而在超出年度预算时为红色。我试图对此使用SWITCH函数,但是它不起作用。任何想法和帮助,不胜感激。这是我正在尝试但不起作用的内容。 E24是我要显示迷你图的单元格。 H是具有实际支出的单元格,F是具有预算金额的单元格。

非常感谢您提供帮助以实现此目标。

= SWITCH(E24, ABS(H24)<F24,(SPARKLINE(H24,{"charttype","bar";"max",F24;"color1","#2E86DE"})),
ABS(H24)>F24,(SPARKLINE(H24,{"charttype","bar";"max",F24;"color1","#de4c60"})),
ABS(H24)=F24,(SPARKLINE(H24,{"charttype","bar";"max",F24;"color1","#69C569"})),
SPARKLINE(H24,{"charttype","bar";"max",F24;"color1","#000000"}))
if-statement google-sheets switch-statement google-sheets-formula sparklines
2个回答
0
投票

这里是起作用的。 :)

=IF(ABS(H17) > F17, SPARKLINE(H17,
         {"charttype","bar"; "max",F17; "color1","#DE4C60"}),  
 IF(ABS(H17) < F17, SPARKLINE(H17,
         {"charttype","bar"; "max",F17; "color1","#2E86DE"}), 
 IF(ABS(H17) = F17, SPARKLINE(H17,
         {"charttype","bar"; "max",F17; "color1","#69C569"}), )))

0
投票

尝试嵌套IF,例如:

=IF(B3 > B1, SPARKLINE(B2:B3,
             {"charttype", "column"; "color", "red"; "highcolor", "blue";  "ymin", 0}), 
 IF(B3 < B1, SPARKLINE(B2:B3,
             {"charttype", "column"; "color", "red"; "highcolor", "green"; "ymin", 0}), 
 IF(B3 = B1, SPARKLINE(B2:B3,
             {"charttype", "column"; "color", "red"; "highcolor", "pink";  "ymin", 0}), )))

粘贴B3

=IF(G3=0, SPARKLINE(E3, {"charttype", "bar"; "max", C3; "color1", "#6AA84E"}),
 IF(G3>0, SPARKLINE(E3, {"charttype", "bar"; "max", C3; "color1", "#2E86DE"}),
 IF(G3<0, SPARKLINE(E3, {"charttype", "bar"; "max", C3; "color1", "#CC0000"}), )))

0

© www.soinside.com 2019 - 2024. All rights reserved.