2 Replies Latest reply on Jul 28, 2016 11:23 PM by Sridhar M

# Using Aggregated Column in Calculated Field

Hello Experts,

Would like to get some help if its possible in Tableau. I have three calculated fields out of which first two are working as expected and in the third calculated field I am trying to use the second calculated field which does the aggregation.

Do we have any work around to use aggregated calculation in a calculated field?

a. Aging_Bucket  => IF [CALENDAR_DATE]<=TODAY() THEN CALENDAR_DATE   --- This gives a list of Calendar Dates

b. AgingBucketTemp=> countd([Aging_Bucket])                                                      --- This gives the Count Distinct number of Calendar Dates ( ex. 1,2,3,4,5 ,6, 7 etc ..depending on the query)

c.  This is the critical step

ActualAgingBucket =>   IF [AgingBucketTemp]== 1 THEN "TODAY"

ELSEIF [AgingBucketTemp])>=2 AND [AgingBucketTemp]<=5  THEN  "2-5 Days"

ELSEIF [AgingBucketTemp])>=6 AND  [AgingBucketTemp]<=10 THEN "6-10 Days"

ELSEIF [AgingBucketTemp])>=11  THEN "11+ Days"

END

--- Here I am trying to calculate the Aging Bucket depending on the value I get in the step b. and Tableau is not allowing me use the second calculated field which is an aggregated value.

Could anyone please guide me on how to get through this?

Thanks!!

• ###### 1. Re: Using Aggregated Column in Calculated Field

Hi Sridhar,

Please can you upload a workbook (pref clean data) so we can see where you have got to and where the problem appears to be.

You are missing an 'End' for calc a. Aging_Bucket and, you have a right parenthesis on each of your logic statements for ActualAging Bucket but I guess this is just a typo for the post.

When mocking this together in Superstore, (without the typos) everything seems fine. See attached.

Steve

1 of 1 people found this helpful
• ###### 2. Re: Using Aggregated Column in Calculated Field

Thanks a lot Steve , the solution worked just as you mentioned. I forgot to convert the "AgingBucketTemp" into continuous and that stopped me in proceeding further.

Yes the END in the if statement was a typo while posting.

Thanks again!!

Sridhar