1 2 Previous Next 17 Replies Latest reply on Apr 14, 2016 11:47 PM by Sharad Adhikari

# Create a calculated dimension

Hi All,

I have a data set like this.

ConsultantPerformance DaysSales
645Pre 90\$ 500
645

Pre 60

\$ 450
645Pre 30\$ 500
645Training days\$ 400
645Post 30\$ 600
645Post 60\$ 650
645Post 90\$ 900

I want to calculate average sales of pre 90, pre 60 and pre 30 days.

Also I want to create a bar chart to show the performance of consultants after training days.

The chart I am able to create is something like this.

But i want the first bar is to be average of Pre 90, pre 60 and Pre 30 days sales

My requirement is something like this.

Pre training average sales= (\$500 + \$450 + \$500)/3

Any help would be much appreciated.

• ###### 1. Re: Create a calculated dimension

Hi Suraj,

Please find the attached tableau workbook which contains the solution for your problem.

I have used the concept of groups and created a calculation for the same. Please take a look at it. Please refer to the screenshot as well for the output.

Thanks and Regards,

Ashish Chaudhari

Note : If this has helped please click on "That helped" and Mark the answer as correct. This will motivate every individual and help those who are facing the same issue.

2 of 2 people found this helpful
• ###### 2. Re: Create a calculated dimension

Hi Suraj,

Please find the solution attached. There might be many ways to do this thing.  I used calculated fields to get the solution.

BR

• ###### 3. Re: Create a calculated dimension

My stone to the fortress, I have used LOD calculation.

• ###### 4. Re: Create a calculated dimension

You guys are really amazing!!

Unfortunately, I am unable to open any of the tableau files as I am using Tableau 8.3 and Tableau 9.0.

Is there any other way or could you please provide screen shots?

That would be a great help for me.

Thank you!!

• ###### 5. Re: Create a calculated dimension

Hi Ashish,

I grouped the pre 90, pre 60 and pre 90 into pre training and

create a calcultaed field like below.

Its working fine.

if [Performance Days] ="Pre 90" or [Performance Month]="Pre 60" or [Performance Month]="Pre 30"

then ([Sales] )/3

else [Sales] End

Please let me know if any other work around is available.

• ###### 6. Re: Create a calculated dimension

Here are my three steps:

This:

IF [Performance Days] = 'Pre 30'

OR [Performance Days] = 'Pre 60'

OR [Performance Days] = 'Pre 90'

THEN 'Pre Training'

ELSE [Performance Days]

END

2 of 2 people found this helpful
• ###### 7. Re: Create a calculated dimension

Hi Suraj,

Open your twb file in notepad and change the version to 9.0 and get older workbook. But this is not good way. Our report format will changed based on older version.Some options also loss in older versions.

Thanks

Ashish

• ###### 8. Re: Create a calculated dimension

Wow!! your solution looks pretty much interesting.

I was trying my hand something like this.

I grouped the pre 90, pre 60 and pre 90 into pre training and

create a calculated field like below.

if [Performance Days] ="Pre 90" or [Performance Month]="Pre 60" or [Performance Month]="Pre 30"

then ([Sales] )/3

else [Sales] End

Its working fine.

Is it the right way?

• ###### 9. Re: Create a calculated dimension

Hi Ashish,

I opened it in notepad, but couldn't find the version.

• ###### 10. Re: Create a calculated dimension

Performance Month?

You need to use ' instead of " in order to reflect that you are referring to the strings 'Pre 90', 'Pre 60', and 'Pre 30'.

Also, when you are calling for IF xxxxxxxx, you need to tell the calculation that the latter will be grouped in a new 'string', Pre Training.

Your calculation is valid but it doesn't lead to the result you wanted to obtain: grouping all PRE entries into one PRE.

This:

IF [Performance Days] = 'Pre 30'

OR [Performance Days] = 'Pre 60'

OR [Performance Days] = 'Pre 90'

THEN 'Pre Training'

ELSE [Performance Days]

END

is the one you should be looking for

1 of 1 people found this helpful
• ###### 11. Re: Create a calculated dimension

Naming conventions are slightly different in application. [Performance Days]= [Performance Month]

I don't know why it was giving the correct result.(After grouping the dimension and using calculated field)

Thank you so much for your help.

• ###### 12. Re: Create a calculated dimension

Ahah, ok then no problem!

Feel free to mark some posts here as "helpful" or even "Correct", if you are satisfied

• ###### 13. Re: Create a calculated dimension

Hehehehehehehehe

• ###### 14. Re: Create a calculated dimension

Hi Ashish,

I have opened your solution. and it seems good. Thank you!!

However, I have a new situation. I have to plot pre training avg sales as a reference line in bar chart.

I am pretty much new in tableau. I guess I'll have to use combo chart/ dual axis chart.

any suggestions?

Lénaïc Riédinger unfortunately we can not use LOD calculations in tableau 8.3.

But its really a joy to watching it work.

1 2 Previous Next