Using CTE to Fetch the Data, the Data is Sometimes not the Latest When the User Opens the Dashboard View

Published: 05 Aug 2021
Last Modified Date: 08 Jul 2022


View using Common Table Expressions (CTE) in Initial SQL, the latest data in Tableau Server is not displayed when a view is refreshed.


  • Tableau Server 2021.1.1
  • MS SQL Server


This is expected behavior since Initial SQL is not run when the view is refreshed. The initial SQL command will run when a connection is made to the database, for example, when you open the workbook, refresh an extract, sign in to Tableau Server, or publish to Tableau Server. Initial SQL is not run when your refresh your view. 

As workaround one of the following options can be used:

Option 1:

Since Initial SQL will run when an extract is refreshed, use extract instead of live data and schedule the extract to be refreshed based on desired frequency.

Option 2:

Use view or stored procedure in SQL Server.
Did this article resolve the issue?