Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
For a graph that I have, we have more then 100 products. If I understood correctly, Qlik only assigns 100 different colors unless you take the time in giving each value a different color making use of a master Item.
For the big picture it isn't that kind of a big deal, but when you make some selections, we have the problem that sometimes, different values use the same color.
Is there a way that Qlik like change the colors it assigned at first when making some kind of selections so that if the filter narrows the products down to less then 100, they all have a different color?
Thank you all for your help.
Hello,
I was taking a look at this interesting use case scenario and I was able to find a workaround that might work for you. You are right that if you have a lot of data, you will notice that the colors are repeated and I can see how this can be a confusion when you filter data and the fields with the same color appear side by side. In my workaround, I have used the function RGB() [1], and through the script I was able to generated different random combinations of colors for each ID.
For example this is my load script:
Data:
LOAD
OrderID,
LineNo,
ProductID,
UnitPrice,
Quantity,
Discount
FROM [...]
(...);
As you can see, it is a dataset with data for orders. Now I want to present my data in Charts and at the same time have a different color based on the LineNo field, so I will create a table that will have all the unique LineNo IDs and each ID will be associated with a particular color.
So first I am creating a temporary table with all the unique IDs:
TempIds:
LOAD
Distinct LineNo as LineNo
Resident Data;
Now I will create a new Colors table which will contain the unique IDs with the random generated values R, G, B:
Colors:
Load
LineNo,
Floor(Rand() * 256) as R,
Floor(Rand() * 256) as G,
Floor(Rand() * 256) as B
Resident TempIds;
And then I will drop the temporary table as it is no longer needed:
Drop Table TempIds;
This process will generate a table that is associated with your data table and will contain the following data:
Then you can create a Bar chart and specify the following details:
The results are:
And since there are many combinations with the RGB codes, it will be very difficult to get an occasion where the color is exactly the same with another field. Additionally, this means that the colors are not repeated, no matter how many values you have.
I hope that this information was helpful
---
Hello,
I was taking a look at this interesting use case scenario and I was able to find a workaround that might work for you. You are right that if you have a lot of data, you will notice that the colors are repeated and I can see how this can be a confusion when you filter data and the fields with the same color appear side by side. In my workaround, I have used the function RGB() [1], and through the script I was able to generated different random combinations of colors for each ID.
For example this is my load script:
Data:
LOAD
OrderID,
LineNo,
ProductID,
UnitPrice,
Quantity,
Discount
FROM [...]
(...);
As you can see, it is a dataset with data for orders. Now I want to present my data in Charts and at the same time have a different color based on the LineNo field, so I will create a table that will have all the unique LineNo IDs and each ID will be associated with a particular color.
So first I am creating a temporary table with all the unique IDs:
TempIds:
LOAD
Distinct LineNo as LineNo
Resident Data;
Now I will create a new Colors table which will contain the unique IDs with the random generated values R, G, B:
Colors:
Load
LineNo,
Floor(Rand() * 256) as R,
Floor(Rand() * 256) as G,
Floor(Rand() * 256) as B
Resident TempIds;
And then I will drop the temporary table as it is no longer needed:
Drop Table TempIds;
This process will generate a table that is associated with your data table and will contain the following data:
Then you can create a Bar chart and specify the following details:
The results are:
And since there are many combinations with the RGB codes, it will be very difficult to get an occasion where the color is exactly the same with another field. Additionally, this means that the colors are not repeated, no matter how many values you have.
I hope that this information was helpful
---
This works, thanks.
Although it deletes the legend from the graph. Do you maybe know a way so that I can still display the legend and have different colors?
I am glad that it helped you achieve the outcome that you were looking for. Regarding the legend, you are absolutely right that it is hidden with this option. I was checking if there is any way of having the legend there, but I was unable to do so. I have noticed that:
One workaround that you can implement, which is not an optimal solution but it works, is to have a combination of the chart with the Table chart that will act as a legend. In the Table chart you can add the same Dimension as the other chart and in the properties of the dimension you can set the "Background color" to "=RGB(R,G,B)" again. This will mean that you can easily see the value and the color that is representing that value. Even if you do some selections, the Table chart will be updated as well.
For example:
and with selected values:
I hope that this information was helpful!
---