Modify data on php level

Concat text

Example with a simple concat: see GoogleMaps Plugin Doc

Calculate an amount

Let say we sum the amount generated in opportunities per sales stage. We add a field to see how much 20% of this sum represents. Outcome:

How it is done:

  • set a variable name for the amount per sales stage => amount in column store
  • add a fixed field => the one labelled 20% of sale stage
  • set a formula in that field => {amount}*0.20

It is of course possible to store multiple names and make more complexe calculations.

Add a color for cell display

This is a workaround by using formula in manipulate tab. It will work great on strings but as soon as you have calculations or currency fields, it won’t work. So be careful using it.

Example: I list opportunities and I want the sales stage field to be red when opportunity stage is “Prospecting"

I store the value for field in a variable that I call “stage"
In formula I write php code and add an html Tag for color:
({stage} == “Prospecting” ? “<font color='red'>”.{stage}.”</font >” : {stage})

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

Be aware that currency fields will break when additional html code is applied. If you need colours for currency amounts, add a fixed value in KReporter and write the formula there. Make sure your custom function parses the currency symbole.

HTML code Formatting will also make problems on exporting data to excel or pdf. Use with caution!

results matching ""

    No results matching ""