I'm connecting to BigQuery to get information for a Sankey Diagram in Tableau. However, I am getting this information from 2 different datasets: "audience exited" and "audience entered". I am using the User IDs and the original timestamps to join the 2 datasets. However, the timestamps are in a datetime format and those times do not coincide with each other across datasets given that a user can exit an audience at 2 a.m and only enter a new audience at 4 a.m. Hence, I am using "FORMAT_DATETIME" to remove the time on the original timestamps i.e: from "2021/07/07 23:32" to "2021-Jul-7" as shown in the SQL code below:
SELECT `audience_exited`.`active_customers` AS `active_customers`,
`audience_exited`.`audience_key` AS `audience_key`,
FORMAT_DATETIME("%Y-%b-%d",auience_exited`.`original_timestamp`) AS `original_timestamp`,
`audience_exited`.`received_at` AS `received_at`,
`audience_exited`.`user_id` AS `user_id`,
`audience_entered`.`active_customers` AS `active_customers__audience_entered_`,
`audience_entered`.`audience_key` AS `audience_key__audience_entered_`,
FORMAT_DATETIME("%Y-%b-%d",`audience_entered`.`original_timestamp`) AS `original_timestamp__audience_entered_`,
`audience_entered`.`received_at` AS `received_at__audience_entered_`,
`audience_entered`.`user_id` AS `user_id__audience_entered_`,
"audience_key" AS Vizside
FROM `dial-a-delivery-ke.personas_personas_prod`.`audience_exited` `audience_exited`
FULL JOIN `dial-a-delivery-ke.personas_personas_prod`.`audience_entered` `audience_entered` ON ((`audience_exited`.`user_id` = `audience_entered`.`user_id`) AND (`audience_exited`.`original_timestamp` = `audience_entered`.`original_timestamp`))
I get the following error when I run it in Tableau:
An error occurred while communicating with the data source
Error Code: 015CFBE6 The Google BigQuery service was unable to compile the query. Syntax error: Expected ")" but got identifier
.
at [5:46]
And I do not know what to make of this since everything seems fine to me. Please can you assist with this error?
'%Y-%b-%d'
. However, if you just want to get from a datetime to its date, I'd suggest to use theDATE
function:date(audience_entered.original_timestamp)
. – Thorsten KettnerON
clause where you compare the dates, rather than in theSELECT
clause? Or have I misunderstood the issue? – Thorsten Kettnerdial-a-delivery-ke
, because without backticks these would be considered four separate column names and some subtractions). But there I'd rather change the names in the database, so they don't require thse ugly backticks. At last: Do you really need a full outer join? You want to select both people that came and never left and others that left and never came? – Thorsten Kettner