# Multiple Functions for colouring cells

**URL:** <https://community.spicecrm.io/t/multiple-functions-for-colouring-cells/240>\
**Category:** KReporter\
**Created:** [January 19, 2018, 10:56am UTC](https://community.spicecrm.io/t/multiple-functions-for-colouring-cells/240 "2018-01-19T10:56:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephen.roy](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@stephen.roy](https://community.spicecrm.io/u/stephen.roy)\
**Post date:** [January 19, 2018, 10:56am UTC](https://community.spicecrm.io/t/multiple-functions-for-colouring-cells/240/1 "2018-01-19T10:56:49Z")

</div>

Hi, i have a formula which displays a stored value and wraps it in a span to change the colour.

({stage} == “Won” ? “

”.{accvalue}."
":{accvalue})

the issue i have is adding a further formula if the {stage} == “lost” how would i go about doing this?

is this a possibility in Kreporter?

---

<div class="post-metadata">

**Author:** ![maretval](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@maretval](https://community.spicecrm.io/u/maretval)\
**Post date:** [January 22, 2018, 9:42am UTC](https://community.spicecrm.io/t/multiple-functions-for-colouring-cells/240/2 "2018-01-22T09:42:17Z")

</div>

Stephen,

when conditional statement becomes more complex than a simple if / else, best practice is to create a custom function in custom/include/custom\_utils.php (create file if not present yet), pass the value in KReporter and return the formatted string.  
Your function could look like  
function kreporter\_opportunities\_stage\_color($stage = “”){  
switch($stage){  
case ‘Qualification’:  
$stage = “\< font color=‘red’\>”.$stage."\</ font \>";  
break;  
case ‘Prospecting’:  
$stage = “\< font color=‘blue’\>”.$stage."\</ font \>";  
break;  
default:   
}  
return $stage;  
}

In Formula in KReporter you would have  
kreporter\_opportunities\_stage\_color({stage});

Please note that space I placed in font tag are only there to avoid the rendering of font tags is this post.  
Val

---

<div class="post-metadata">

**Author:** ![stephen.roy](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@stephen.roy](https://community.spicecrm.io/u/stephen.roy)\
**Post date:** [January 31, 2018, 6:47pm UTC](https://community.spicecrm.io/t/multiple-functions-for-colouring-cells/240/3 "2018-01-31T18:47:43Z")

</div>

Thank you Val. we have this working perfectly.
