After the creation of dashboards in Tableau, if there is a problem from the SQL side, it means Custom SQL. Rather than using custom SQL connections in Tableau, it is better to use SQL statements creating a view inside of the database, then connecting that to Tableau. This will streamline the efforts without hunkering them down with the rest of the SQL, which are generated by Tableau without the custom SQL subquery.
Check out this blog to know How to Build a Tableau KPI Dashboard!