Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Paknanarn23
Creator II
Creator II

I want to add color to a bar graph.

I want to add color to the bar graph by entering the Expression background color.

Paknanarn23_0-1701498236465.png

The conditions are If the bar graph shows data for the year, include rgb(30,144,255) and if the graph shows data for the month, enter Rgb(70,130,180) and if the graph shows data for the day, enter rgb(135,206,250)

This is the code that displays the data in a bar graph.

Paknanarn23_1-1701498358632.png

please help me

10 Replies
rubenmarin

Hi, I can't read anything on that image, can you paste as text?

Paknanarn23
Creator II
Creator II
Author

=if(KCE_MonthYear>=Date(AddMonths(Today(0)-1,-1),'YYYY-MM-01'),date(KCE_Date,'MM/dd/YY'), >> Day
if(KCE_Year>Year(Today(0)-1)-1,date(KCE_MonthYear,'$(vMonthYearFormat)'), >> Month Today
if(KCE_Year>Year(Today(0)-1)-3,KCE_Year))) >> Year 2022 2021 

rubenmarin

Hi, if I understood it well I think you can use the same expressión but setting the color code:

=if(KCE_MonthYear>=Date(AddMonths(Today(0)-1,-1),'YYYY-MM-01'),RGB(136,206,250),
if(KCE_Year>Year(Today(0)-1)-1,RGB(70,130,180),
if(KCE_Year>Year(Today(0)-1)-3,RGB(30,144,255))))

 

Paknanarn23
Creator II
Creator II
Author

Paknanarn23_0-1701683088419.png

I have implemented your code. But my 2021 and 2022 bars are not the required color.

rubenmarin

Yes, I didn't check the expression, remove the -1, or use >= instead of >)

if(KCE_Year>Year(Today(0)-1),RGB(70,130,180),
if(KCE_Year>=Year(Today(0)-1)-1,RGB(70,130,180),
Paknanarn23
Creator II
Creator II
Author

Thank you for helping me. But when I edit the code like yours My color on the month bar still hasn't changed.

Paknanarn23_0-1701827681275.png

if(KCE_MonthYear>=Date(AddMonths(Today(0)-1,-1),'YYYY-MM-01'),RGB(136,206,250),
if(KCE_Year=Year(Today(0)-1)-3,RGB(30,144,255),
if(KCE_Year=Year(Today(0)-1)-1,RGB(70,130,180))))

Paknanarn23
Creator II
Creator II
Author

This is the color I want.

Paknanarn23_0-1701832496556.png

 

rubenmarin

Hi, it hosuld be >= or remove the -1, and without changing the order inside the if:

=if(KCE_MonthYear>=Date(AddMonths(Today(0)-1,-1),'YYYY-MM-01'),RGB(136,206,250),
if(KCE_Year>=Year(Today(0)-1)-1,RGB(70,130,180),
if(KCE_Year>=Year(Today(0)-1)-3,RGB(30,144,255))))

 

Paknanarn23
Creator II
Creator II
Author

I tried adding your code to expressions, but the colors didn't turn out the way I wanted. It will appear only when I click on the month chart. What should I do?

This is where I put your code

Paknanarn23_1-1701924495268.png

And when I click to select the month The bar graph shows the colors I want.

Paknanarn23_2-1701924533752.png