Yes this is possible.
This is one way that it could work:
Outward facing Tableau Server
When a user lands on your search engine page it creates a session and stores a session ID, example: 12345
The user then submits the search.
The results then gets stored in a database table with whatever structure you need and extra column for "SessionID"
Your Tableau Server visualization has a live connection to this table with a Custom SQL parameter in the WHERE clause that filters to SessionID = <paramters.session> // This will filter the data down to only the sessionID 12345
Your webpage will need an iframe with the visualization embedded in it and pass in the sessionID through the URL string.
//Below is an example in PHP. $sessionID is a php variable that holds 12345.
<iframe src="http://myserver/views/searchworkbook/searchview?:embed=yes&:tabs=yes&:toolbar=yes&session=<?PHP echo $sessionID; ?>" width="800" height="600"></iframe>
each user will see only their version of the search results in the view.
You will need the database table that stores all of this info to be cleared on a very consistent basis and based off of the age of the records that were inserted so as to not have a giant table with slow performing queries.
If Tableau were able to dynamically connect to tables based on parameters then you could created and drop tables based off of user sessions and not worry about table size but this is not current functionality in Tableau.
Thanks a lot!
No problem, circle back if you do try something like this as it would be a nice example of what people are doing with Tableau. I did something similar last year but it was for internal users and it wasn't based off of sessions but rather User ID's of my web portal.
Aaron Clancy wrote:
"If Tableau were able to dynamically connect to tables based on parameter then you could ..."
Tableau can do this as of version 8.1.
Data connections can reference parameters inside custom SQL.
Oh nice, you can dynamically change table names in the connection string?
If that's the case. instead of creating a giant table you might consider creating individual tables per session, it all depends on how many users you expect to have and how many results you plan on storing for a visualization.
Hi Aaron Clancy
I dont understand the Custom SQL parameter part: SessionID = <paramters.session>
What is <paramters.session> supposed to be ?
For example, this is my custom sql:
$sessionID = 2;
SELECT "test_db"."_id" AS "Xid",
"test_db"."date" AS "date",
"test_db"."comment" AS "comment",
"test_db"."sessionID" AS "sessionID"
WHERE sessionID = ??? //what is it supposed to be?
Database is Mongo db
Alex Blakemore I tried using a parameter as a table name and it still doesn't appear to be tableau functionality. Parameter passing has worked for some time now but has never been able to modify anything other than the WHERE clause of the query, which is what I described in my above description.
paul.p The <parameters.session> portion is a Tableau Parameter that you insert into your custom SQL of your datasource for your visualization. You would create a parameter that is of type string (if your sessionID is a string) and then insert that into the WHERE clause of your query.
I probably should have prefaced with: in order to pull this off you should be well versed in Tableau and server side web development.
I've never seen an implementation with MongoDB. You would either have to find an ODBC driver for it or use a different DB in order to work with Tableau.
Info for Tableau and MongoDB: http://community.tableau.com/thread/109795
I have a feeling your code will have to convert Mongo to a tabular source before connecting with Tableau.
This would just be one more step in the PHP code that inserts records from Mongo into an other DB that is usable with Tableau.
MySQL is lightweight and easy to integrate with PHP.
example Tableau workbook Custom SQL:
When you embed the published workbook you can pass the "session" parameter through the URL string so that the query that populates the visualization changes depending on what sessionID was passed.
Great! I'll try this and get back.
I was actually able to get an ODBC driver for MongoDB to Tableau... Simba MongoDB ODBC
I changed to MySQL, and using this custom SQL with the parameter:
where `test_db`.`sessionID` = <Parameters.session>
but I keep getting this error:
[MySQL][ODBC 5.2(w) Driver][mysqld-5.5.24-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`id`,
`test_db`.`' at line 3
Unable to connect to the server "localhost". Check that the server is running and that you have access privileges to the requested database.
What am I doing wrong?
You'll have to troubleshoot your syntax.
There's a lot of factors that could go in to why the query doesn't work.
Have you used custom SQL parameters in Tableau before?
Does the query work without the parameter inserted?
When you created the parameter did you make it a string or an integer?
did you populate the default value of the parameter to a test value?
I can see the mistake. Its the <Parameters.session> at the beginning..so obvious, dont know how I missed that.
Now it works!
I changed it to
where `test_db`.`sessionID` = <Parameters.session>
lol I honestly didn't think you had that at the beginning of the query. I thought you just mistyped your forum post.
According to the online help, "parameters can only replace literal values. They cannot relpace expressions or identifiers such as table names".
Its still a useful technique, but not as flexible as I thought.