Filo
March 1, 2024, 5:14pm
1
Hello Team!
With the following data:
|Date|Value|
|2021-04-01|1|
|2021-05-01|9|
|2021-06-01|9|
|2021-07-01|3|
I was asked to do the following:
find the most recent period
for this period check if value is smaller than 9
value smaller than nine is green, otherwise red
Present in a form of a bar chart
I calculated it in the following way:
Find last Date (Created artificial aggregate, IDK if needed?):
max(Date, [{Artificial aggregate}])
Check if date is last date and apply colours if needed:
ifelse(
max(Date)=max({BC - last date}),
ifelse(max(Value)>=9,‘red’,‘green’),‘empty’)
It works like charm for a table - the test column is a source for conditional formatting and values colour accordingly:
I can’t, however, use this calculation in colour group for the bar chart - custom aggregations are not allowed.
Could you advise me with a solution to this issue?
The dashboard:
Most recent period - bar chart colouring
duncan
March 1, 2024, 10:44pm
2
Hello @Filo !
Could you try something like the following calculated field and apply it to your Group/Color By field?
ifelse(
Profit >= 1,
"Good",
Profit <= 0,
"Bad",
NULL
)
For “Good” and “Bad” you can use the metric that you are measuring for, just applying them as if they are string values. Essentially you are turning the conditions into groups for your data.
Then, change the color of the bars in the visual menu by clicking on the bar and assigning the color by group.
Let me know if that helps!
Filo
March 2, 2024, 11:10pm
3
Hello @duncan ! Thanks for reaching out
I am not sure if this is enough for this case, sadly. I can create a calculation that colours each bar charts depending on value, but the issue I’m facing is that it should be applied for the last period only. The way I see it, this requires table calculation/aggregation that is not allowed for grouping field. I was wondering if this is achievable in QS
So,
find last period
colour last period depending on value
(The rest of the bar charts can be coloured in gray, for example)
Below all bars coloured
The state I am aiming at:
Thanks for help!
Filo
March 4, 2024, 2:05pm
4
… is there a way to colour last bar only, for starters?
duncan
March 4, 2024, 3:47pm
5
Hello @Filo !
Got it, I believe what you are describing is not supported yet, but looks like it is something that is on the Quicksight teams radar:
Is it possible to conditionally format bar graphs and line charts? I know the QuickSight documentation says it is only available for gauge charts, KPIs, Pivot tables & tables, but I am wondering if there is a workaround that anyone has discovered?
If not, how do we have this raised as a feature request?! Would be great to have. I have a lot of customers that I work with who like to have their bar graphs and line graphs formatted based on RAG conditions.
I have a dataset which i am using for learning. It is fruit production for UK, France, and Spain, from 2014-2018. I am focusing on UK, on the fruit “Pears”. I have a chart which i want to show the percentage difference for each year in production of Pears.
It looks like this:
[image]
It is quite simple, but i want to colour anything above 0% green, and anything below 0% red. So it colours whether it was a positive or negative difference.
The only problem is that i can’t use a calculated fie…
I will mark this a feature request for the Quicksight team!
1 Like