4 Replies Latest reply on Aug 13, 2016 2:18 PM by Sandris Jermacans

# IF function for Calculated field

Hi,

I have tried all possible functions but I am getting all sorts of errors, can anybody help me to solve this task?

I want to make a Calculated field that looks up previous value in [RowA]  and if it the same as a current [RowA]  value it assigns 0 to [RowB] if not assigns current  [RowA] cell value to [RowB]. This is expected result.

[RowA]   [RowB]

4               4

5               5

5               0

5               0

6               6

7               7

• ###### 1. Re: IF function for Calculated field

You cannot 'assign' values to a dimension or a measure. You can create a calculated field to calculate an outcome though.

Here's an example of a calculated field which should do what you're after;

if lookup(attr([Row A]),-1) = attr([Row A]) then sum(0) else attr([Row A]) end

• ###### 2. Re: IF function for Calculated field

With this formula it shows "Undefined" in all cells    I can mention that both fields are set as Number(whole) type.

• ###### 3. Re: IF function for Calculated field

Hi Sandris,

You will need to upload a Tableau Packaged Workbook which includes sample data so I can replicate.