Upcoming SlideShare
×

# Tableau + Redshift views for dummies

1,869 views
1,505 views

Published on

Small presentation for an in house training showing how to use Redshift views to avoid problems while filtering our main events table.

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,869
On SlideShare
0
From Embeds
0
Number of Embeds
57
Actions
Shares
0
18
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Tableau + Redshift views for dummies

1. 1. Tableau + Redshift views for dummies
2. 2. GOAL Generate a new table with the desired data
3. 3. No, no, no, no We are not going to: • Delete • Insert • Update (for the moment…)
4. 4. What we use Redshift (PostgreSQL 8.0.2) Tableau 8.1 Workbench / Navicat / Aginity workbench (for previous exploration)
5. 5. Selecting columns Select A, C FROM table; A B C 1 ES 10 2 DE 20 3 ES 30 4 FR 40 3 ES 40 6 FR 60 A C 1 10 2 20 3 30 4 40 3 40 6 60
6. 6. Selecting columns and rows A B C 1 ES 10 2 DE 20 3 ES 30 4 FR 40 3 ES 40 6 FR 60 A C 1 10 3 30 3 40 Select A, C WHERE B = ‘ES’ FROM table;
7. 7. Transforming data A B C 1 ES 10 2 DE 20 3 ES 30 4 FR 40 3 ES 40 6 FR 60 Select A, SUM(C) AS revenue FROM table GROUP BY A; A revenue 1 10 2 20 3 70 4 40 6 60
8. 8. Transforming data with operators A B C 1 ES 10 2 DE 20 3 ES 30 4 FR 40 3 ES 40 6 FR 60 Select A, (C – C*.3) AS benefits FROM table; A benefits 1 7 2 14 3 21 4 28 6 28 6 42
9. 9. Mathematical operators Select A, (C – C*.3) AS benefits FROM table; Operator Description Example Result + addition 2 + 3 5 - subtraction 2 - 3 -1 * multiplication 2 * 3 6 / division 4 / 2 2 % modulo 5 % 4 1 ^ exponentiation 2.0 ^ 3.0 8 |/ square root | / 25.0 5 ||/ cube root || / 27.0 3 @ absolute value @ -5.0 5 Math functions: http://docs.aws.amazon.com/redshift/latest/dg/Math_functions.html
10. 10. What seems to work better 1. Create a view in Redshift 2. Add the view to the table 3. Edit the Join if needed 4. Ready to go
11. 11. Create a view in Redshift CREATE OR REPLACE VIEW public.payingusers SELECT transactions.user_id, sum(transactions.amount_in_dollars) AS revenue FROM transactions WHERE transactions.amount_in_dollars > 0::numeric(12,4) GROUP BY transactions.user_id;
12. 12. What seems to work better 1. Create a view in Redshift 2. Add the view to the table 3. Edit the Join if needed 4. Ready to go
13. 13. Add the view to the table • In Data select Edit Tables… and add the view
14. 14. What seems to work better 1. Create a view in Redshift 2. Add the view to the table 3. Edit the Join if needed 4. Ready to go
15. 15. Edit the Join if needed • In Tables select Edit… and check the Join.