6 Replies Latest reply on Feb 17, 2016 10:46 AM by K P

    Automated dashboard image

    K P

      Hello Tableau Gurus.

      My requirement is simple, But I don't know how to do it.

      I have one dashboard on tableau server.

      I want to generate image of that dashboard every week automatically.

      and save that image somewhere that can be accessible via some web URL without any credentials.

      Can someone give me step-by-step instruction for at least automating the image saving every week?

      Thanks

        • 1. Re: Automated dashboard image
          K P

          Generating pdf will also work.

          Thanks

          2 of 2 people found this helpful
          • 2. Re: Automated dashboard image
            Tyler Garrett

            Yes, we have a few scripts for doing this task. Automated version is posted below in PowerShell.

             

            Source code posted below and also we explain it in this blog post.

            How to do Tableau Server Automated Dashboard Image - A Solution here

             

            Thanks

            Tyler G.

            Dev3lop.com

            2 of 2 people found this helpful
            • 3. Re: Automated dashboard image
              Derrick Austin

              Hey Kush,

               

              You can do this with tabcmd's export function. Here is the documentation: tabcmd Commands

               

              After installing tabcmd, it is basically the following, on a scheduled basis:

               

              tabcmd login -s http://sales-server -t Sales -u administrator -p aPasswordHere

              tabcmd export "Finance/InvestmentGrowth" --png

               

              - Derrick

              https://www.interworks.com/blog/daustin

              4 of 4 people found this helpful
              • 4. Re: Automated dashboard image
                Tyler Garrett

                Derricks works great for quick and easy manual means of doing it. I would recommend taking that path unless you're running bigger jobs.

                #_______________________________Start here

                #  PNG EXPORT Script

                #  A powershell script to pull down pngs of Tableau "views"

                #

                #  Created By - Tyler Garrett

                #

                #

                #  || NOTES ||

                #  Create Directory C:\POSH\PNGExport

                #  This directory will store all content

                #  Script expects Tableau Bin directory to be set in Environment Variable Path

                #_______________________________

                 

                 

                #________________________________

                #  Set variables

                #________________________________

                $TS       = "http://localhost"          #Server

                $username = "admin"                     #tableau server account

                $pass     = "admin"                     #tableau server password

                $pgUSR    = "readonly"                  #readonly account password must be setup beforehand

                $pgPW     = "admin"                     #postgres password

                $SiteF    = "BeepTest"                  #site you're pulling PNGs from

                $ProjectF = "ProjectTest"               #project you're pulling PNGs from

                #_______________________________

                cd C:\POSH\PNGExport

                #_______________________________

                #--------------=====================]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

                #¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

                #                                                             |

                #   Query postgresql and build CSV with workbook URL (3 steps)|

                #                                                             |

                #¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

                #                                                         |

                #             1.Connection info                           |

                #                                                         |

                #¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

                Set-Location "C:\POSH\PNGExport"

                function Get-Stuff

                {

                    [CmdletBinding()]

                    param (

                            [string]$connectionString,

                            [string]$query

                          )

                    Write-Verbose 'Getting Tableau Server Extract'

                    $connection = New-Object -TypeName System.Data.Odbc.OdbcConnection

                    $connection.ConnectionString     = $connectionString

                    $command = $connection.CreateCommand()

                    $command.CommandText = $query

                    $adapter = New-Object System.Data.Odbc.OdbcDataAdapter $command

                    $dataset = New-Object -TypeName System.Data.DataSet

                    $adapter.Fill($dataset)

                    $dataset.Tables[0]

                }

                #¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

                #                                                         |

                #             2.Query PostgreSQL                          |

                #                                                         |

                #¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

                $connectionString = 'Driver={PostgreSQL ANSI(x64)};Server=localhost; Port=8060; Database=workgroup; Uid='+$pgUSR+'; Pwd='+$pgPW+';'

                $query = @"

                SELECT

                         v.view_url

                FROM     _views v

                INNER JOIN _workbooks w on (w.id=v.workbook_id)

                INNER JOIN _sites s on (s.id = v.site_id)

                WHERE s.name = '$SiteF'

                and w.project_name = '$ProjectF'

                "@

                #¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

                #                                                         |

                #   3.Build CSV to be used for tabcmd from the above query|

                #                                                         |

                #¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦

                Get-Stuff -connectionString $connectionString -query $query | `

                Select-Object -Skip 1 -Property view_url | `

                Export-Csv -Path "C:\POSH\PNGExport\Reports.csv" -NoTypeInformation -Delimiter ";"

                #--------------=====================]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

                #_________________________________

                #  Loop through CSV from above and export those views as PNG files

                #  -replace is used in the loop to save the file name with out a "/"

                #  because this value isn't allowed in a file naming convention

                #  error output will be generated in the folder

                #_________________________________

                tabcmd login -s $TS -u $username -p $pass -t $SiteF

                ForEach ($wb in @(Import-Csv -Path C:\POSH\PNGExport\Reports.csv | select -expand view_url) )

                {

                    Try

                        {

                            $newwb = $wb -replace "/", "_"

                            tabcmd export $wb --png -f $newwb 2>> C:\POSH\PNGExport\TabCmdGetWbErr.txt

                        }

                    Catch

                        {

                            Write-Error -Message “Error occured: $_”

                        }

                }

                #_________________________________

                #  Convert PNG to BMP - helps people who are moving these photos into Powerpoint

                #  Comment the Dir *.png.... line out of the script if you want to keep them as PNG files

                #_________________________________

                Dir *.png | rename-item -newname {  $_.name  -replace '\.png$','.bmp'  }

                tabcmd logout

                #_______________________________End here

                 

                 

                Cheers,

                 

                Tyler Garrett

                founder

                Dev3lop

                5 of 5 people found this helpful
                • 5. Re: Automated dashboard image
                  Kenneth McBride

                  I'm curious about this line Tyler:

                  Dir *.png | rename-item -newname {  $_.name  -replace '\.png$','.bmp'  }

                   

                  What's the point of renaming the .png to a .bmp since it isn't actually converting the image file?

                  • 6. Re: Automated dashboard image
                    K P

                    Hello All,

                    Thank you so much for responding so fast.

                    For me just creating the BAT file and run it with windows task scheduler did the trick. thank you

                    "C:\Program Files\Tableau\Tableau Server\9.2\bin\tabcmd.exe" login -s http://servername/ -u username-p password

                    "C:\Program Files\Tableau\Tableau Server\9.2\bin\tabcmd.exe" get "/views/workbook/worksheet.pdf" -f "C:\Users\TEST.pdf"

                    TYLER GARRETT, I am going to note your answer for future. currently requirement is for only one dashboard.

                    it is very informative and helpfull.

                     

                    Thank you all once again. I love this forum.

                    1 of 1 people found this helpful