Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a table whose rows I am looking to color according to the textual value in ColumnC (see exemple below). If I have 3 possible values in ColumnC then I would have 3 colors. I cannot know before which values that will be in the ColumnC (it depends on the data) therefore this color assignment must be somehow dynamic. How to do it?
Thanks.
Dynamic Random coloring:
Data:
LOAD *,
//AutoNumber(ColC, 'ColorID') as ColorID,
RGB((AutoNumber(ColC, 'ColorID') * 85) , (AutoNumber(ColC, 'ColorID') * 170) , (AutoNumber(ColC, 'ColorID') * 255) ) as Random_Color
// color(fieldindex(ColC, 'ABXX12')) as random_color
INLINE [
ColA, ColB, ColC
zderf, 12, ABXX12
sdesf, 0, SDZE23
hfdrjjnct, 134, ABXX12
sarthv, 125, QSX23
dmllrto, 35, SDZE23
];
UI:under all dims and measure, color: =only(Random_Color)
Usually we maintain a seperate excel for color codes and formats, in case you have one, you have to map them o the data and proceed as above.
=pick(match(ColC, 'ABXX12', 'SDZE23','QSX23' ), rgb(125,125,0), blue(), red()) //put your own color codes in place
Try to use this expression for each dimension and measure background.
Thanks. My problem is that 'ABXX12', 'SDZE23','QSX23' are examples but the values in ColumnC will change each time depending on the user's selection. I'm looking for a generic way to be able to assign as many colors as there are values in this ColumnC.
Dynamic Random coloring:
Data:
LOAD *,
//AutoNumber(ColC, 'ColorID') as ColorID,
RGB((AutoNumber(ColC, 'ColorID') * 85) , (AutoNumber(ColC, 'ColorID') * 170) , (AutoNumber(ColC, 'ColorID') * 255) ) as Random_Color
// color(fieldindex(ColC, 'ABXX12')) as random_color
INLINE [
ColA, ColB, ColC
zderf, 12, ABXX12
sdesf, 0, SDZE23
hfdrjjnct, 134, ABXX12
sarthv, 125, QSX23
dmllrto, 35, SDZE23
];
UI:under all dims and measure, color: =only(Random_Color)
Usually we maintain a seperate excel for color codes and formats, in case you have one, you have to map them o the data and proceed as above.
I have posted generic/dynamic coloring code too.