Description: STYLE(...) inside certain functions seems to be called when it should not, even if the rest of the formula seems to work normally. Steps to Reproduce: 1. Start a new spreadsheet 2. Pick a cell... any cell. Insert this formula: ="foo"&SWITCH( 0,0,3&STYLE("Neutral"),-1,5&STYLE("Bad"),+1,7&STYLE("Good")) 3. Recalculate (F9) a few times. Actual Results: The cell's value is "foo30", toggling between "Bad" and "Good" (red and green) styles. Expected Results: The cell shows "foo30" in "Neutral" style (yellow) Reproducible: Always User Profile Reset: No Additional Info: Without the first (unused) STYLE exactly the same happens. Without either 2nd or 3rd "&STYLE", the cell toggles between the other one and "Neutral" instead. If the first argument is 1 or -1, the value is picked from the correct branch, and toggling is still between the last 2 styles. First it looked like SWITCH function is broken, but it's something weirder. The same happens if you replace SWITCH with CONCATENATE - correct output value, STYLE toggles. But SWITCH is supposed to ignore wrong branches, thus there should be no possibility of racing in GUI or anything like that. This does not happen with IF: ="foo"&IF( 0=0,3&STYLE("Neutral"), 5&STYLE("Bad")) The result: "foo30" painted yellow as expected. Does not depend on whether OpenGL and jRE are enabled or not. Version: 5.4.1.2 Build ID: 1:5.4.1-0ubuntu1 CPU threads: 2; OS: Linux 4.13; UI render: default; VCL: x11; Locale: en-US (en_US.UTF-8); Calc: group User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0
Reproduced. For ; separated style: ="foo"&SWITCH(0;0;3&STYLE("Neutral");-1,5&STYLE("Bad");+1,7&STYLE("Good")) Arch Linux 64-bit, KDE Plasma 5 Version: 6.0.0.0.alpha1+ Build ID: 1aba1955f161cc112dab80b6b3e78ec7761616fc CPU threads: 8; OS: Linux 4.13; UI render: default; VCL: kde4; Locale: fi-FI (fi_FI.UTF-8); Calc: group Built on November 10th 2017
Possibly related to other weird parsing/branching errors in IFS and some other functions - see Bug 111675.
IFS() and SWITCH() currently evaluate all parameters' arguments in order encountered from right to left and return the result matching for the condition(s). They do not short-cut evaluation like IF() and CHOOSE() do. Hence for a function that has side effects like STYLE() all styles are applied and the last one wins.
*** This bug has been marked as a duplicate of bug 111675 ***