8 Replies Latest reply on Jun 7, 2013 3:35 AM by Demon Glory

Calculated field

Hi Friends,

I am trying to calculate the percentage of customers navigating from one page to another. I have a calculated field say first_page_cnt which evaluates like,

if dir='first page' then sum(count)

Similarly, i have a calculated fields for each page.

I have then created another calculated field to plot in graph and this field uses condition as shown below,

if dir='first page' then 2000

else if dir = 'second page' then second_page_cnt / first_page_cnt

end

The problem is, the else condition is not working as I understand that, both the if condition is not satisfied for Second page & first page.

My question is how can i use the value of first page count to divide it? In BOBJ, i was able to acheive this using WHERE function which is not available in tableau.

Any help on this would be appreciated.

• 1. Re: Calculated field

if dir='first page' then 2000

else if dir = 'second page' then second_page_cnt / first_page_cnt

end

Try:

IF [dir]='first page' THEN 2000

ELSEIF [dir]='second page' THEN second_page_cnt / first_page_cnt

END

--Shawn

• 2. Re: Calculated field

Hi Shawn,

Thanks for the reply. I have tried that, but it doesn't work.

The Problem is, Tableau evaluates like this,

IF [dir]='first page' THEN 2000

ELSEIF [dir]='second page' THEN second_page_cnt / first_page_cnt -----> IF [dir]='Welcome' then sum(cnt)

EN

Since both the If conditions are not true for the particular record, its not returning the value.

Thanks,

Sikkandar!

• 3. Re: Calculated field

I'm confused. What is stored in [dir] and what do you want to do if a condition is true? And what do you want to happen if all conditions are false?

--Shawn

• 4. Re: Calculated field

My data looks like this,

dir               count

first page     1000

second page     800

I would like to calculate as shown below,

if [dir] ='first page' then 2000 --Hard coded value

ELSEIF [dir]='second page' then 800/1000

END

How can I achieve this?

Thanks,

Sikkandar

• 5. Re: Calculated field

Just like you've written it. What sort of error are you getting?

--Shawn

• 6. Re: Calculated field

this is just a sample data and i can not hard code on the calculations. I have the same type of data for each day and trying to plot between the counts & date.

I have created 2 calculated fields first_page_cnt & second_page_cnt to store each page count.

I have created another calculated field as shown below,

IF [dir]='first page' THEN 2000

ELSEIF [dir]='second page' THEN second_page_cnt / first_page_cnt

END

ELSEIF Condition is not working and it is NULL which is the problem i am facing.

• 7. Re: Calculated field

I think you're going to have to mockup and post a packaged workbook with a bit of sample data for me to help you any farther.

--Shawn

• 8. Re: Calculated field

What about the data manged in grids? May be they are structured or assigned with the help of strong back end..Are you tried SQL to fix this?

1099 software