5 Replies Latest reply on Jul 6, 2016 1:12 PM by Luciano Vasconcelos

# Combine strings and metric to show a box with percentage change vs. yesterday caption

I want to have a text box on a dashboard that gives a total value for today, then underneath it have a text box that will have "+/- n% vs. yesterday" and the text box background turn green/yellow/red depending on the percentage value.  I have the textbox for the value for the current day and it seems like I need to have a sheet for each value and then arrange them on the dashboard to make it look the way I want it to.  In Reporting Services or Business Objects it would be easy to do this, I could create an expression something like this:  IF [percentage calc] >= 0 THEN "+" ELSE "-" + Str([Percentage Calc]) + " vs. yesterday", but I can't seem to figure out how this would be one in Tableau.  I want it to look something like below and then I can build a drill through to get to more detailed visualizations.  Any help is greatly appreciated.

• ###### 2. Re: Combine strings and metric to show a box with percentage change vs. yesterday caption

The sample data is in the picture I included, but a basic example is:

Today revenue: \$50,000

Yesterday Revenue: \$49,000

Change vs. Yesterday: +2%

• ###### 3. Re: Combine strings and metric to show a box with percentage change vs. yesterday caption

Something like this:

Today:

Sum(If [Date] = Today() then Revenue End)

Yesterday:

Sum(If [Date] = Today() -1 then Revenue End)

▲ = (Today / Yesterday) - 1

• ###### 4. Re: Combine strings and metric to show a box with percentage change vs. yesterday caption

Thanks for the response.  I'm not having any problems with the calculations, what I'm having problems with is getting a text box (or cell in a table) to show the calculation with dynamic text.  Let's say I have a calculated field called [Pct Chg Yesterday], I want the value in the cell to have a concatenation of "+" or "-" depending on if it was a positive or negative change + [Pct Chg Yesterday] + " vs. yesterday".  So, if the change was +2% from yesterday, the textbox/cell would display "+2% vs. yesterday" and the background would be green.

• ###### 5. Re: Combine strings and metric to show a box with percentage change vs. yesterday caption

It's just use the main KPI and put the others on text and edit.