4 Replies Latest reply on Jul 11, 2018 3:28 AM by Glen Swan

# Combine two or more metrics in one field

How can you combine two or more metrics (or even calculated metrics) into one field or column?

For example, I have two metrics. One is the previous day and one is the current day. I created a calculated metric that displays the difference in percentage from the previous value from the current one. This metric works as intended. Now from a visualization standpoint, I would like to display the field as: \$280,380 (37%) as the value. This is essentially combining the 280,380 with the 37% into one field.

If you can, please explain as opposed to uploading a Tableau sheet. I'm working with Tableau Public.

• ###### 1. Re: Combine two or more metrics in one field

Hi Glen,

I've create a dummy data to evaluate the result. If you've similar data as per the sample attached below then find my approach,

Create few calculated fields

Current Day Sales which is 7/10/2018 : 125

IIF(DATETRUNC('day',[Date])={MAX(DATETRUNC('day',[Date]))},[Sales],NULL)

Previous Day Sales which is 7/9/2018 : 115

So, growth %: (125-115)/115 is 8.7%

(SUM([Current Day Sales])-SUM([Previous Day Sales]))/SUM([Previous Day Sales])

If you drag these fields on canvas then you'll have this view

Now, to get the final output as per requirement, you just need to put these calculated fields on label like this and edit the label as per attachment

Let us know if this help else share some sample mock up data in packaged workbook/excel.

Workbook v10.5 attached for your reference.

Mahfooj

• ###### 2. Re: Combine two or more metrics in one field

Thanks!

I was sure I could do this with a text field. The big question is: can you do this with the matrix/tabular graph? Is it possible to have this listed in the cell? I would assume not without first doing the transformation to the data before it gets loaded into Tableau?

• ###### 3. Re: Combine two or more metrics in one field

Sounds doable Glen.

It'll be helpful for us to give you any solution, if you share some sample mock up data either in packaged workbook or in excel with your expected output.

Mahfooj

• ###### 4. Re: Combine two or more metrics in one field

Here is the report I'm referencing. Trying to get present and past difference in percentage into one field within the table.