Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Newbie777
Partner - Creator III
Partner - Creator III

Coloring measures by dimension for employee tenure gantt chart

Hello,

I'm currently putting together employee tenure gantt chart and I've managed to make some progress thanks to the Qlik Community. My current employee tenure chart sorted by joining date order looks like below, but I'd like to use a blue color for male employees and a red color for female employees in order to distinguish and visualize gender in the chart below.  I'd greatly appreciate it if you could let me know how I can do that.  

 

Newbie7_0-1623566754528.png

Thanks a lot for your help!

 

1 Solution

Accepted Solutions
Newbie777
Partner - Creator III
Partner - Creator III
Author

This issue was solved by creating two measures for each gender with color association in each measure and stacking up together in a stacked bar chart.  

View solution in original post

6 Replies
Newbie777
Partner - Creator III
Partner - Creator III
Author

Regarding my question above, after my novice online research, I have a feeling that the solution could be achieved by combining measures 

Alt(date([Leave date]), today(0)) - Alt([HR changes.Hiring date], today(0))

and 

if(Gender='M',blue(),red())

I'd appreciate it if anyone could let me know how I could combine the time dimension measure and color function above to be used in the 2nd measure in a horizontal stacked bar chart.  

Thank you for your guidance.  

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Expand Appearance -> Colors and Legend.  Uncheck Color Custom and select "By Expression".  Enter your gender color expression in the input box. 

https://help.qlik.com/en-US/sense/May2021/Subsystems/Hub/Content/Sense_Hub/Visualizations/Bar-Chart/...

2021-06-13_08-39-03.png

Newbie777
Partner - Creator III
Partner - Creator III
Author

Thanks for your response. However, because my horizontal stacked bar chart has two measures, 'Hiring Date' and Tenure, and I want to white (or no fill) color to 'Hiring Date' master measure, and I just want the Tenure measure to be color coded by the color expression of blue for male and red for female, the solution above alone does not produce what I need, as it colors not only Tenure measure but also 'Hiring Date' measure by that expression.  I guess I need something like if formula to specify if the measure is Hiring Date, use white color and if the measure is Tenure, follow the color coding if-expression, but I am not familiar with Qlik Sense syntax and I don't know how to do this.  I'd appreciate it if anyone can let me know how I can achieve what I am trying to do.  

Newbie777
Partner - Creator III
Partner - Creator III
Author

I'd appreciate it if anyone could let me know how I can write color expression when there are two measures which I want to apply different color conditions.  If it is 'Hiring date' measure, I want it to be white for both male and female, but if it is 'Tenure' measure I want it to be blue for male and red for female.  I know now how I can combine the color expression if formula with the different conditions for two measures. 

Newbie777
Partner - Creator III
Partner - Creator III
Author

This issue was solved by creating two measures for each gender with color association in each measure and stacking up together in a stacked bar chart.  

andreykh
Partner - Specialist
Partner - Specialist

Just in case, feel free to experience our Gantt Charts for Qlik Sense, with various features and extensive settings for customization.

Overview | Download | Documentation | Demo apps | Schedule a live demo

qlik gantt.gif

"How to Create a Decomposition Tree in Qlik Sense: Transform Root Cause Analysis [Video Tutorial]" — Watch now!