Apply icon depending on the text value in the cell

Asked

Viewed 4,307 times

2

Assuming as example the column E, the value of which Sim or the value Não, I am trying to create a conditional formatting that applies an arrow depending on the text present in the cell itself:

Sim   = Verde
Não   = Vermelho  
outro = Amarelo  

The point is that this doesn’t seem to work with text, only with numbers because by default it already assumes a comparison >=.

If you use numbers, I get the desired result:

Formatação Condicional com base numérica

Which results in:

Resultado da Formatação Condicional com base numérica

But the problem is -1, 0 and 1 are not humanly readable (except for the programmer...).

Question

In the Libre Office Calc, how to apply an arrow automatically based on a text value present in the cell itself?

If impossible, an acceptable alternative is to apply a later format to conditional formatting where the value 1 is presented as Sim, and the value -1 as Não.

Example of the spreadsheet: example.ods

  • 1

    You tried to use a formula that "translates" the text automatically to 1, -1 or 0 (for example, using the function SE)? By the way, you could share a minimal example of the spreadsheet, just to facilitate the tests of those who help. :)

  • 1

    @Luizvieira I added an example spreadsheet. The function SE I haven’t tried it yet, I’ll test it. Tks!

  • 1

    I was testing here, but it seems that it applies conditional formatting only that it does not display when the content is text. I did the following test: I applied the formatting in the column using a formula that references the next column; it does not display the icons, but if I change the value of a cell to numeric, then it displays the icon. It seems that my suggestion will not work, because the resource is only for cells of numerical value... :(

  • @Luizvieira My tests before asking the question also made me come to this conclusion...

1 answer

3


The problem seems to be really the fact that this kind of conditional formatting (Icon Set) only work for numerical data types. But I did not find official confirmation for this suspicion anywhere on the Internet (just found indication that it is impossible to use a custom set of icons, because the image is compiled together with the Libreoffice source code).

Anyway, I figured out a way to do what you want with the alternative that you yourself suggested: actually use numeric values in the cell, but display them to the user in text form. To do this, just create new styles specific to the texts "Yes", "No" and "Other".

  1. Open the Styles window by going to the "Format Menu" (Format) -> "Styles and Formatting" (Styles and Formatting) - in my Libreoffice, which is in English, the hot key is F11.

inserir a descrição da imagem aqui

  1. In this window, right-click on the base style (Default) and select new. You will need to create a style for each discrete value of your data (that is, one for "Yes", one for "No" and one for "Other" - as in your example). Name your style in the main tab.

inserir a descrição da imagem aqui

  1. In the "Numbers tab" (Numbers), select the user-defined format in the category (User-defined, in my case in English) and type the string you want to appear (in quotes! ) in the formatting code field (Format code). Click Ok and this style will be recorded.

inserir a descrição da imagem aqui

  1. Do the same for all styles. At the end you will get something like this:

inserir a descrição da imagem aqui

  1. Now, go to the data column you want to format (which, of course, should contain numeric values 1, 0 or -1 instead of text) and normally add the conditional icon formatting (Icon Set) you were already using. Then click "Add" (Add) to include a new simple formatting by choosing the value and style to be applied.

inserir a descrição da imagem aqui

  1. Repeat for all possible values/styles (in your example, at the end you will have 4 simultaneous conditions: that of the icons, and 1 for each possible text "Yes", "No" and "Other"). Once applied, your data will be displayed as you wish, although the value of the cells is still numerical (as you can notice by the number displayed above, where indicated in red).

inserir a descrição da imagem aqui

  • 1

    Impeccable, a little laborious, but as it is reusable, Impeccable! :)

  • Remember that you can also apply the style (text, not conditional icon formatting) manually to a cell using the style function in a formula. Since it always returns 0, you can do, for example: =1+Style("Yes"). You only need to fix the conditional icon formatting. The rest you control when updating cells. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.