Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Creator III
Creator III

Text color expression

Hi experts

I try to change the text color via an IF condition:

=if(

Budget = 'Yearly' and Calendar.MonthNum='12',   white(), black()

)

But this code is ignoring the case if MonthNum is 12. Any ideas?

Thanks, Tom

Labels (5)
1 Solution

Accepted Solutions
QFabian
Specialist III
Specialist III

@TomBond77 , what about this?

Data:
Load * INLINE [
Calendar.MonthNum, Amount, Type
1, 100,a
2, 50,b
3,100,a
4,50,a
5,10,a
6,50,b
7,100,b
8,50,b
9,100,a
10,50,b
11,30,a
12,40,b
];

exit script;

QFabian_0-1672929292856.png

QFabian_1-1672929310625.png

 

 

color :

=if(SubStringCount(Concat(Calendar.MonthNum, '|'), '12') > 0 , white(), black())

QFabian

View solution in original post

6 Replies
QFabian
Specialist III
Specialist III

Hi @TomBond77 , maybe this?

=if(

Budget = 'Yearly' and num(Calendar.MonthNum) = 12,   white(), black()

)

QFabian
TomBond77
Creator III
Creator III
Author

Hi QFabian

There is a filter on MonthNum. If Jan up to Nov is filtered, the cell should be white. If the last month comes additionally into the filter the cell value should give black. Any ideas?

=if(Budget = 'Yearly' , if(num(Calendar.MonthNum)>=1 and Num(Calendar.MonthNum)<12 , white(), black()))

QFabian
Specialist III
Specialist III

@TomBond77  i made this example, and effectively, the row for 12 Month is black :

QFabian_0-1672926618251.png

 

QFabian
TomBond77
Creator III
Creator III
Author

This only works if MonthNum is an element of the table, etc. Our filter is based on dimension Month (like Jan, Feb, ...Dec). Is there another function to use Calendar.Month as dimension?

QFabian
Specialist III
Specialist III

@TomBond77 , what about this?

Data:
Load * INLINE [
Calendar.MonthNum, Amount, Type
1, 100,a
2, 50,b
3,100,a
4,50,a
5,10,a
6,50,b
7,100,b
8,50,b
9,100,a
10,50,b
11,30,a
12,40,b
];

exit script;

QFabian_0-1672929292856.png

QFabian_1-1672929310625.png

 

 

color :

=if(SubStringCount(Concat(Calendar.MonthNum, '|'), '12') > 0 , white(), black())

QFabian
TomBond77
Creator III
Creator III
Author

Thank, brilliant!