6 Replies Latest reply on Sep 12, 2016 8:41 AM by Matthew McHale

# How do I aggregate logical statement outside of the view?

Hi all,

I'm really stumped here trying to calculate a count based on dates and a field not in the view.  I apologize if i'm not explaining this clearly.  I assume this should be a simple question.  Below are the formulas and a view of the data:

Issues Pre Purchase: IF ATTR([Repair date]) < ATTR([Warranty start]) OR ISNULL(ATTR([Warranty start])) AND [Count of Issue ID] > 0 THEN [Count of Issue ID] END

Issues Post Purchase: IF ATTR([Repair date]) >= ATTR([Warranty start]) THEN [Count of Issue ID] END

I'm trying to get the view below without having the repair date, issue ID, or count of the issue ID in the view from above.  I'd like to total the count for pre and post and display it without the other data in the view.  It looks like since the issue ID isn't in the view it won't display the count If I have a VIN with more then one issue with dates that fall into the different categories it only shows the one.

Thanks,

Matt

• ###### 1. Re: How do I aggregate logical statement outside of the view?

Hi Matthew,

You could make your calculations to become Row-Level ones, like this:

// Issue IDs Pre Purchase

IF ISNULL([Warranty Start]) OR [Repair Date] < [Warranty Start]

THEN [Issue ID] END

// Issue IDs Post Purchase

IF [Repair Date] >= [Warranty Start]

THEN [Issue ID] END

Then you could use COUNT() or COUNTD() of those, depending on a view.

Yours,

Yuri

• ###### 2. Re: How do I aggregate logical statement outside of the view?

Hi Yuriy,

Thanks for your help with this.  I tried what you said and something still isn't right.  You can see below that the number of issues IDs pre and post are high based on the count of issue id.  Is there any other advice you could give so I get the correct calculated number?

Thanks Again,

Matt

• ###### 3. Re: How do I aggregate logical statement outside of the view?

Hi Matthew,

Is it by chance that you're using

SUM() aggregation as a default one for your

[Issues Pre Purchase] and [Issues Post Purchase]

together with a modification as suggested by yours truly?

Then the big numbers are simply SUM() or Issue IDs,

which are indeed big numbers themselves.

to get correct numbers on a view.

Yours,

Yuri

• ###### 4. Re: How do I aggregate logical statement outside of the view?

Hi Yuri,

That took care of it so it's perfect now.  Thanks so much for your help and guidance on this.

Is there any easy way to identify calculations that work at the row/line level compared to my previous formula?

I'm pretty new to creating formulas so the more information and guidance on this I get the better.

Thanks Again,

Matt

• ###### 5. Re: How do I aggregate logical statement outside of the view?

As for calculations (Row-Level vs Aggregate vs Table Calcs),

this is a good primer for everyone working with Tableau,

highly recommended:

https://www.tableau.com/learn/training

Go to the bottom of the page and find the section

"Why is Tableau Doing That?"

The first two videos are a must.

Yours,

Yuri

• ###### 6. Re: How do I aggregate logical statement outside of the view?

Awesome,

Thank you!

Matt McHale

Quality Engineering Data Analyst - Quality Assurance

*T: *+1 (201) 818-8482

Jaguar Land Rover North America, LLC.

555 MacArthur Blvd., Mahwah, NJ 07430

jaguarusa.com  |  landroverusa.com

On Mon, Sep 12, 2016 at 11:34 AM, Yuriy Fal <tableaucommunity@tableau.com>