4 Replies Latest reply on Mar 15, 2016 10:52 AM by ann.stolzman

# Calculating fare estimate

I am working on a dashboard that shows fare estimate from a starting point (start) to a hospital by taking uber. I created two parameters that lets you select which hospital to go to and which uber to take. Then created calculated fields that shows the distance depending on the hospital and another one that shows how much it is per mile depending on the uber type. Then I created another calculated field 'fare estimate' to show the estimate (distance x rate per mile) and the formula is valid but not showing anything when I drag it to the view. I think the key problem is to get the 'per mile' data from the uber type dataset.

Below are my calculated fields..

which_hospital

case [Hospital]

when "4601 Martin Luther King Jr Ave SW, Washington, DC 20032" THEN [Distance1]

when "1310 SOUTHERN AVENUE SE" then [Distance2]

END

which_uber

case [uber_type]

when "UberBLACK" THEN ATTR([estimate (estimate)].[Per Mile])

when "UberSUV" THEN ATTR([estimate (estimate)].[Per Mile])

when "uberX" THEN ATTR([estimate (estimate)].[Per Mile])

WHEN "uberXL" THEN ATTR([estimate (estimate)].[Per Mile])

when "uberX + Car Seat" then ATTR([estimate (estimate)].[Per Mile])

END

fare estimate

SUM([which_hospital])*[which_uber]

What am I doing wrong in the calculations and is there a better way to approach this problem? (Attached my workbook)

Any feedback would be appreciated.

Thank you!

• ###### 1. Re: Calculating fare estimate

Seona,

Check your data relationship fields: Start (in your distance data) does not equal Type (in your estimate data) - the fields have to have the same data in them.  Start is your hospital address, and Type is your uber type - nothing will ever calculate like that.  You need to have a field with the same/similar data in it to get this to work.

-Ann-

1 of 1 people found this helpful
• ###### 2. Re: Calculating fare estimate

Seona,

I've also attached a workbook (in Tableau 9.2.4) that shows what I did - does this get you where you need to be?  Or at least closer?

-Ann-

1 of 1 people found this helpful
• ###### 3. Re: Calculating fare estimate

This is perfect! Thank you Ann!

• ###### 4. Re: Calculating fare estimate

No problem Seona,

Can you mark the answer as correct if it's really the solution to your problem?  That helps keeps the community clean, the unanswered question queue clean, and helps others if they're searching for similar things.

-Ann-