2 Replies Latest reply on Jan 30, 2019 10:40 AM by Yantezia Patrick

# Creating Exception within Existing Calculation

Hi there,

This is probably covered somewhere deep in the calculations forum, but I couldn't find it and I need a bit of help.

I'm working on a simple index in Tableau, which includes marketing metrics like impressions, clicks, page position, etc. I've created a calculated field to return the appropriate measure for a parameter, ie.

IF [Parameters].[All Metrics Selector] ='total impressions' THEN [Total Impressions]

ELSEIF [Parameters].[All Metrics Selector]='total clicks' THEN [Total Clicks]

And so it goes on, because I have a line graph that the parameter belongs to, but feel free to ignore the idea of a parameter right now. What I need assistance with is the following calculation for the index: ([All Metrics Selector])/(LOOKUP(ZN([All Metrics Selector]), -1))*100

The index is currently calculated as current year/previous year. However, I have one metric (page position) that needs to be calculated previous year/over current year. How can I amend the current calculation to account for this one calculation that needs to be switched around?

Thanks!!

• ###### 1. Re: Creating Exception within Existing Calculation

The [All Metrics Selector] calc is the one you inserted part of above, right?

Set the addressing for your LOOKUP calc as usual.  But make a separate calc for [Page Position].  Make it do its own thing.

Make one more calc.

IF [Parameters].[All Metrics Selector]='page position' then [Page Position Lookup Calc] else [General Metric Selector Lookup Calc] END

Use that final calc in the viz.

1 of 1 people found this helpful
• ###### 2. Re: Creating Exception within Existing Calculation

Thanks so much, Joe! My apologies for the delayed response; I was in the midst of work and on a deadline to get this problem solved. Your advice worked 100%; your a lifesaver.

Cheers,

YP