3 Replies Latest reply on Aug 30, 2017 12:43 AM by Ben Topper

# Aggregate Row Problem in IF Formula

Hi All,

I've got the following Tableau table which is based off the following data in excel

I want to display the sum of the "measure" column, unless Dimension 1 = A and Dimension 2 = X, in which case it should add 1 (i.e. get 7).

I tried a formula which says:

IF [Dimension 1] = "A" AND [Dimension 2] = "X"

THEN [Measure] + 1

ELSE [Measure]

END

But this gives me 9 instead of 6 because Tableau adds 1 to each of the three rows in the database.

I tried ... THEN SUM([Measure]) + 1 .... but this tells me that I can't mix aggregate and non-aggregate results in an if formula.

I've created a simple packaged workbook to illustrate the problem.

Thanks,
Ben

• ###### 1. Re: Aggregate Row Problem in IF Formula

Hi Ben,

Here you go. Format you formula as follows. Please mark it completed so that the ticket is closed.

Thanks,

Mani

• ###### 2. Re: Aggregate Row Problem in IF Formula

Thanks Mani!

• ###### 3. Re: Aggregate Row Problem in IF Formula

Hi Mani,

Following on from this, I used the same basic syntax, but realized that it won't work with a filter on the product. I'm linking here in case anyone else has the same issue.

Thanks,

Ben