Text Facet (not alphabetical order)

Hi. I need to create a text facet but not following alphabetical order. I'd like to see different item following the order they appear in its column. I created a second column IDX with an id number (1, 2, 3, ...) assigned to unique values. Thanks, Fabio

Hi @fabiolinus could you give an example of what some simple data might look like and how you'd like that to appear in the facet? I haven't quite understood the result you are trying for at the moment

Hi Stephens. Thanks at all. I will try to explain me. This is your column: B, A, B, B, A, A, B. Only two distinct values: A and B. Text facet show you: A followed by B. No blank values are present.

This is your column: B, A, B, B, A, A, B. Only two distinct values: A and B. Customer Text facet shows you: B followed by A. No blank values are present. In order they appears, A follows B. Right?

Don't you?

Hi @fabiolinus :

B, A, B, B, A, A, B
B, A, B, B, A, A, B

seams to be the same data to me. What am I not understanding?


Hi Antoine! Sorry for my bad example. I will try to explain me. Yes, they are the same because they are the same input for OR. That's it. But I am interested in the output (Text Facet). By default, Text Facet show me A like first item; then B like second item and so on (alphabetical order). But I am interested in a customized Text Facet.

B, A, B, B, A, A, B

In this example B cames before A because your unique values are B and A, ......... I'd like to have a customized Text Faced which shows B, A, ......Is this more clear? Thanks for your effort, Fabio

Hi @fabiolinus,

So, if I understand, you would like that the order of items in the Text Facet to appear in the same order they exists in the dataset?

Regards, Antoine

If you want a (very hacky) way of doing this right now, you can sort of do it by creating a custom text facet with a "cross" expression

So if I have a project called "Alphabet" that contains one column "Letters"


Then you can create a custom text facet on the letters column with and expression like:

value.cross("Alphabet","Letters")[0].index.toString("%04d")+" "+value

This will create a facet with values:

0000 B           4
0001 A           3
0007 D           1
0008 C           1

This is using the row.index from the first occurrence of the value in the column (found by the cross expression) with a bit of formatting to make sure "2" sorts before "10" etc.

Does that help?

Thanks a lot for your effort. This is a very good and practical solution for me. I didn't know the cross() command. I can think to change 0000, 0001, 0007 and 0008 to 01, 02, 03 and 04 for semplicity. But it is not so important at the moment. Thanks again, Fabio