Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
wayne-a
Creator
Creator

KPI with different text colors

Hi, I have a KPI as in the example below, I've highlighted the two numbers at the end.

KPI Example.PNG

 

The code for the expression is below, I use the Num function to format variables that are performing the calculations:

='Revenue for YTD-' & $(vLabelCurrentYear) & ' was ' & Num($(vAmountCurrentYear),'$#,##0.00;-$#,##0.00') &
', Revenue for YTD-' & $(vLabelPriorYear) & ' was ' & Num($(vAmountLastYear),'$#,##0.00;-$#,##0.00') &
', for a difference of ' & Num($(vAmountCurrentYear)- $(vAmountLastYear),'$#,##0.00;($#,##0.00)') & ' Or ' & Num($(vDifferenceYear),'#,##0%;(#,##0%)')

What I'd like to do is change the text color for the difference and percentage numbers at the end if they are negative.  I'm not having any luck with trying to wrap formatting functions around the calculations.  I can find lots of examples of changing the color of all the text but not a part of it.  I saw an example where someone did this but I believe it was in Qlik View or they may have put multiple KPI objects next to each other.

Thanks in advance for any help or assistance.

1 Reply
H_Julian
Contributor III
Contributor III

To my knowledge, there is no way in Qlik Sense to format the color of part of a string in a text box.

You could instead create a text box with the first part of the Text, then a KPI box with the Numbers in it(there you can code the Colour in an if statement and rgb-codes)Textbox again('or') and the another KPI box with the last Number

You might face issues with the size of the Text and Numbers, so therefor maybe stick to Textboxes, but still divide them into several with colour coding for the KPI's

Greetings

Julian