You may need to create a new
table with a stored procedure. We recommend using a stored procedure if the
situation meets any of the criteria below:
The data needs a:
- Dynamic view
- Custom SQL data connection
- Complex multiple table
joins
With a dynamic view, performance
in Tableau can be poor because SQL must rebuild the entire view with each
query. If you switch the dynamic view to a materialized view, SQL returns
the data to Tableau more efficiently.
With a complex Custom SQL
connection, Tableau cannot optimize the queries and must complete the
entire SQL statement each time. If you change the complex SQL statement to
a materialized view, Tableau can optimize performance.
In the case of a complex join,
the SQL Query may take significant time to return the results of the query.
By front-loading the query into a materialized view, SQL can provide the
data to Tableau faster.
A table-valued function allows
the return of an actual table object that can be connected to in Tableau. A
quick example of such a function is provided below. The key part of this
function is RETURNS TABLE AS RETURN, which brings back the result as a
table Tableau can read. To invoke this function from the Edit Custom SQL
dialog box in Tableau Desktop, use this kind of query syntax:
SELECT * FROM [Superstore
4.1].[dbo].[SuperstoreTableFunction]
('east')
This query returns a subset of
the total data set. There is a wide variety of potential solutions when you
use table functions to pre-aggregate or otherwise filter data on certain
criteria.
EXAMPLE OF TABLE-VALUED
FUNCTION IN SQL SERVER:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
--
=============================================
-- Author: Tableau Example Function
-- Create date: 12/12/2008
-- Description: Examples
-- this function assumes a table exists called dbo.Orders
-- =============================================
CREATE FUNCTION [dbo].[SuperstoreTableFunction]
(
-- Add a parameter for this function with seeded default value
@region varchar(20)='west'
)
RETURNS TABLE
AS
RETURN
(
select
[Order ID],
[Order Date],
[region],
[Order Priority],
[Order Quantity],
[Sales],
[Discount],
[Ship Mode],
[Profit],
[Unit Price],
[Shipping Cost],
[Customer Name],
[Customer State],
[Zip Code],
[Customer Segment],
[Product Category],
[Product Sub-Category],
[Product Name],
[Product Container],
[Product Base Margin],
[Ship Date]
from dbo.Orders
where region=@region
)
- Dynamic view
- Custom SQL data connection
- Complex multiple table
joins
|
"House of Business Intelligence" ?? perhaps...
ReplyDelete"House of Good, Clear Website design" ?? ummmm #FAIL
couldn't agree more!! can't read thing even though the material is useful.
DeleteThis tableau Functions are very usefull .Thank you for sharing
ReplyDeleteTableau Online Training
Osmaniye
ReplyDeleteErzurum
NevÅŸehir
Malatya
Tokat
Adıyaman
Çorum
Balıkesir
Urfa