0
votes

I am looking for difference of two columns in Tableau. I have the formula with me.

IF ATTR([Valuation Profile]) = "Base" THEN 
LOOKUP(ZN(SUM([Value])), 1) > - ZN(LOOKUP(SUM([Value]),0)) END

But I get it as a separate column in the columns sections. How do I get that in the rows section? Basically how to get the difference as a dimension?

Please see attached images of what I want and what I have. Apparently, I cannot upload my excel sheet and tableau worksheet here. So I have upload just the screenshots.

What I have - vs - What I want

Tableau Workbook

2

2 Answers

1
votes

First off, there is no way that you can generate additional rows for your data in Tableau! In your case however you could use a workaround and do the following:

  • Create a calculated field for BASE and one for CSA. The formula should be IF [Valuation Profile] = 'BASE' THEN [Value] END and IF [Valuation Profile] = 'CSA' THEN [Value] END respectively
  • Afterwards you can drag Measure Names onto your rows shelf and
  • replace the SUM([Value]) with your two newly created calculated fields

that should give you all three measures in different rows in your table

1
votes

Reference: https://community.tableau.com/message/627171#627171

Use LOD expression to calculate the individual values first. Create calculated fields 'BASE', 'CSA' and 'CSA-BASE' as below.

BASE:

{FIXED [Book Name]: SUM( if [Valuation Profile] = 'BASE' then Value else 0 end ) }

CSA:

{FIXED [Book Name]: SUM( if [Valuation Profile] = 'CSA' then Value else 0 end ) }

CSA-BASE

[CSA]-[BASE]

Solution