5 Replies Latest reply on Jun 20, 2012 6:36 AM by Ranjan Sahoo

# aggregation and non-aggrenation issue facing continuously in if clause.

Hi,

I am facing continuously facing aggregation and non-aggregation issue.

Find the same attachment. Is there any some solution to the issue

Any one can hep.I think many people would have faced.

Thanks,

Ranjan

• ###### 1. Re: aggregation and non-aggrenation issue facing continuously in if clause.

In the first you are mixing row level calculations with calculations across multiple rows. This may help: http://www.theinformationlab.co.uk/2012/03/27/tableau-for-excel-users-part-2-calculated-fields/

Can you explain what you want the first calc to actually do, and where the numbers are coming from?

At the moment it looks like you check each row, then if it meets criteria, use a value that is from multiple rows.

• ###### 2. Re: aggregation and non-aggrenation issue facing continuously in if clause.

Sometimes this can be fixed by using attr - your calc would become

if attr([Period]) = [Parameter] ...

basically putting attr anywhere you have a row level calc.

1 of 1 people found this helpful
• ###### 3. Re: aggregation and non-aggrenation issue facing continuously in if clause.

Hi Alex,

when i have a variable V= sum(Y)/sum(Y)

or simply V1 = sum(X)

then i am trying to do like

If period=a parameter then V

else V1 end

or if simple contains(period,Q4)

then V1

I am getting issue

Any idea. Attr is not working.

Thanks,

Ranjan

• ###### 4. Re: aggregation and non-aggrenation issue facing continuously in if clause.

Hi Ranjan,

Since an aggregation is being used on one field in the calculation, each field within the formula must also be aggregated. So it would look something like the following:

if (attr([Period])=attr([Period Parameter]) then

(if attr([Capability])='Hardware' and attr([Asset ID])=' ') then

....(the rest of the calc)

end

Hope this helps!

-Tracy

• ###### 5. Re: aggregation and non-aggrenation issue facing continuously in if clause.

Hi Tracy,

Thanks.I am sorry.I have earlier seen the same,but couldn't check as i have been to leave. Hence couldn't check. It is working fine. It seems you have changed the reference to 'Ranjan' from 'Ranjoo'. Infact 'Ranjoo' is called by my family. I didn't mind atall. Thank you very much.Can you suggest me how to handle the following issue.

if ([Region] not in ('APMEA','Canada','Europe','Latin America','US')

I am using 'or' for the same. But seems,something is going wrong. Can you please help me.

Simply query using or is not working:

if (attr([Region])  <>'APMEA' or attr([Region]) <> 'Canada' or attr([Region]) <> 'Europe' or attr([Region]) <> 'Latin America'or attr([Region]) <> 'US')

and (attr([Period_Trends]) <> '2006' or attr([Period_Trends]) <> '2007' or attr([Period_Trends]) <> '2008')  then (sum([Total number of stores having HOT(Incl FOE)]) / sum([Total Stores SW]))

elseif (attr([Region]) <> 'APMEA' and attr([Period_Trends]) = '2007') then 2.5

end

Thanks,

Ranjan