Is There any way to Create Different Color Gradient Bar chart

Hi Everyone,
I have a requirement to create a bar chart where the colors of the bar is based on certain conditions, Where,
If the value of a measure (Probability ) is
Low: Less than or equal to 30% then Red
Medium: Between 30% and 70% then Yellow
High: Greater than 70% then Green

Please help is we can do this in any way in quick sight?

Hi @Naveed , How can we add color conditions to Rules? I can only see the options to Hide and Show the visual. Nothing is there to change the color or make the bar graph Gradient
image

Hi,

Please note the Conditional formatting is available on the following visuals:

  • Gauge charts
  • Key performance indicators (KPIs)
  • Pivot tables
  • Tables

image

Here is the document you can follow it for formatting.

Regards,
Naveed Ali

Hi @Ganga,
You can achieve the desired behavior by creating a calculated field for each condition (Low, Medium, High) and then adding each field as a value to a stacked bar chart and picking the color for each condition, by selecting it in the legend.

Here is a quick example, in which we color the bar differently depending on the number of records by month within the dataset:
Let’s say you define 3 calculated fields such as

  • low_bucket: ifelse(count(Customer)<=100,count(Customer),0)
  • mid_bucket: ifelse(count(Customer)>100 AND count(Customer)<=200,count(Customer),0)
  • high_bucket: ifelse(count(Customer)>200,count(Customer),0)

In the following screenshot you can see the difference between using the regular count by month on the right side vs the colored count using the calculated fields on the left side:

Did this answer your question? If so, please help the community out by marking this answer as "Solution!

Hi @Thomas , I will try this approach, But Have one question, I need a stacked bar chart, which is, in a single bar itself the probabilities need to be plotted. Ie,
X axis-Week
Y axis - Terms
Color-Probability,

As of My requirement, I need to color the bars based on probability, and that cannot be used as value, since we have to use Terms (Another Measure) as Y axis. Ie, Terms in range of 0-10 is the Y axis and probability is for colorcoding the bars .Is there any solution to this approach.

The approach should work for that scenario as well. If I want (in my example) to color by number of customers, but actually show the summed up sales figures, I simply adjust the calculated fields as follows:

  • low_bucket: ifelse(count(Customer)<=100,sum(Sales),0)
  • mid_bucket: ifelse(count(Customer)>100 AND count(Customer)<=200,sum(Sales),0)
  • high_bucket: ifelse(count(Customer)>200,sum(Sales),0)

The new graph shows the sales figures by month, but keeps the color-coding based on the number of customers:

Did this answer your question? If so, please help the community out by marking this answer as "Solution!

Hi @Thomas , Thanks for the update. But This is not working in my case.
I have done the same, But I need get my Bar’s Hight based on Forecasted Terms . Not based on the bucket Value. Bucket value is only used for color coding. Not updating the Bar Y axis /Height

Is it possible that you share the expressions of your calculations? This way it might be easier to make a concrete suggestion for you case.

I am Using the Below calculations. Now The Bar height is updated based on Forcasted terms. But here I cannot achieve the solution What I am expecting. So here I am attaching the calculation i am doing for the buckets and what i am expecting
High Bucket:- ifelse(Probability>70,{Forcasted Week Terms},0)
Medium Bucket:- ifelse(Probability>30 and Probability<=70,{Forcasted Week Terms},0)
Low Bucket:- ifelse(Probability<=30,{Forcasted Week Terms},0)

And this is the visual I am getting

As u can see the probability for week 2 in this graph is showing as 25.02. But based on my data, I have 2 distinct probabilities, So I need to show case that both, So for week 2 bar,I need 2 colors.

Thanks for sharing more details. I’ve adjusted my example to check the condition and count the number of occurrences in each bucket at a specific dimensional level (in my case ‘Industry’).

My updated calculated fields look like this:

  • monthly_industry_sales: sum(Sales,[extract('MM',{Order Date})+extract('YYYY',{Order Date})*100, Industry])
  • low_bucket: ifelse({monthly_industry_sales}<=1000,1,0)
  • mid_bucket: ifelse({monthly_industry_sales}>1000 AND {monthly_industry_sales}<=10000,1,0)
  • high_bucket: ifelse({monthly_industry_sales}>10000,1,0)

These calculations then result in the following visual output:

The left graph shows the number of industries that fall into each of the bucket by month.

Did this answer your question? If so, please help the community out by marking this answer as “Solution”!

@Ganga, did this solution work for you? I am marking this reply as, “Solution,” but let us know if this is not resolved. Thanks for posting your questions on the QuickSight Community!

Hi @Xclipse , Yes this solution works for me. Thank You So Much for the Guidance @Thomas

1 Like