Calculating Difference between Two Variables from One Column

Hey guys,

Could someone help me with Calculating a difference between two Measures, BUT - The difference is coming from two variables in one column.

So, I have a column called "Category" and there are only two Variables in there called HELOC 2017 and HELOC 2018.  And I want to calculate the Difference from the measure called "Target Group %" by "Category".

I have tried several methods.

First, I used Tableau's default difference calculation and made changes on the table calculations.

ZN(SUM([Target Perct 2017])) - LOOKUP(ZN(SUM([Target Perct 2018])), 0)

This works BUT- I cant view by "Category".

I also made 3 Calculated Measures, They are:

1. IF [Target] = "HELOC Category 2017" THEN [Target group %] ELSE NULL END

2. IF [Target] = "HELOC Category 2018" THEN [Target group %] ELSE NULL END

3. [Target Perct 2017]-[Target Perct 2018]

But the 3rd Calculated Measure gives me a null value.

The first Screen shot is ultimately what i want but to show that across my Target Dimension Column correctly.

Any help would be greatly appreciated.

• 1. Re: Calculating Difference between Two Variables from One Column

Hi Guen,

Please be sure first and second calculations are not giving null.

Tableau wnt do arithmetic operations on Null.

Eg: Null-78= Null

## Replace Null with 0 may be gives you result.

IF [Target] = "HELOC Category 2017" THEN [Target group %] ELSE 0 END

or

By using Null functions replace the null value with 0 . i hope this will help you.

Thanks,