Tableau - auto-mate/CheatSheetWiki GitHub Wiki
Case Examples
CHEAT SHEET
Data Filters
Datetime To Date
Graph Creation
IF
Linking Data Fields
Makedate Examples
New Field
Parameters
Table Creation
Tableau graphs Example
Create a combination line bar graph
Using Example Data
Date Time Type Forc Forc MC Forc LB Act Act MC Act LB HPH
01/07/2021 00:00 DATA 26 12 14 31 18 13 30
02/07/2021 00:00 DATA 52 24 28 52 36 16 30
03/07/2021 00:00 DATA 78 36 42 73 54 19 30
04/07/2021 00:00 DATA 104 48 56 94 72 22 30
05/07/2021 00:00 DATA 130 60 70 115 90 25 30
06/07/2021 00:00 DATA 156 72 84 136 108 28 30
07/07/2021 00:00 DATA 182 84 98 157 126 31 30
08/07/2021 00:00 DATA 208 96 112 178 144 34 30
09/07/2021 00:00 DATA 234 108 126 199 162 37 30
10/07/2021 00:00 DATA 260 120 140 220 180 40 30
11/07/2021 00:00 DATA 286 132 154 241 198 43 30
12/07/2021 00:00 DATA 312 144 168 262 216 46 30
13/07/2021 00:00 DATA 338 156 182 283 234 49 30
14/07/2021 00:00 DATA 364 168 196 304 252 52 30
15/07/2021 00:00 DATA 390 180 210 325 270 55 30
16/07/2021 00:00 DATA 416 192 224 346 288 58 30
17/07/2021 00:00 DATA 442 204 238 367 306 61 30
18/07/2021 00:00 DATA 468 216 252 388 324 64 30
19/07/2021 00:00 DATA 494 228 266 409 342 67 30
20/07/2021 00:00 DATA 520 240 280 430 360 70 30
21/07/2021 00:00 DATA 546 252 294 451 378 73 30
22/07/2021 00:00 DATA 572 264 308 472 396 76 30
23/07/2021 00:00 DATA 598 276 322 493 414 79 30
24/07/2021 00:00 DATA 624 288 336 514 432 82 30
25/07/2021 00:00 DATA 650 300 350 535 450 85 30
26/07/2021 00:00 DATA 676 312 364
27/07/2021 00:00 DATA 702 324 378
28/07/2021 00:00 DATA 728 336 392
29/07/2021 00:00 DATA 754 348 406
30/07/2021 00:00 DATA 780 360 420
31/07/2021 00:00 DATA 806 372 434
03/07/2021 00:00 WEEKEND_MARKER 600
04/07/2021 00:00 WEEKEND_MARKER 600
10/07/2021 00:00 WEEKEND_MARKER 600
11/07/2021 00:00 WEEKEND_MARKER 600
17/07/2021 00:00 WEEKEND_MARKER 600
18/07/2021 00:00 WEEKEND_MARKER 600
24/07/2021 00:00 WEEKEND_MARKER 600
25/07/2021 00:00 WEEKEND_MARKER 600
31/07/2021 00:00 WEEKEND_MARKER 600
Add Data Data / New Data Source/ Connect To Data etc…
- [Date Time] field to “||| columns” shelf
- Click on new [Date Time] item in “||| columns” tray and select “Exact Date” from Drop Down
- Add value for [HPH] (Hours per head) to “Rows” shelf
- Change to “Bar” in “Marks” Pane
- Drop [Type] Field onto “colour” in “marks” pane (All stacked values are from the same field split by other fields value)
- On [Type] Field in “marks” pane select sort/manual and move to required [position
- in “Marks” Pane click labels button and select layout
- Adding Lines ----
- Drag first of line items “Actual” to become item 2 in “rows” shelf
- Select “Actual” in “Marks” pane and change to “line” graph
- Select “Actual” in “Rows” Shelf and select dual analysis
- Drag additional line fields to right axis until two green bars visible and drop
NB Float legend - only in Dashboard
Can be made in Data area or worksheet Example Right Click in "Measures" on worksheet and select "Create"/"Calculated Field" In Data Click an header and do the same Example For a field called Yesterday
//Change name From Calculation1 to Yesterday then add
MAKEDATE(DATEPART('year',NOW() -1),DATEPART('month',NOW() -1),DATEPART('day',NOW() -1))
//Code For: Yesterday
MAKEDATE(DATEPART('year',NOW() -1),DATEPART('month',NOW() -1),DATEPART('day',NOW() -1))
//Code For: First Day Of Month
MAKEDATE(DATEPART('year',NOW() -1),DATEPART('month',NOW() -1),1)
CASE MID(TRIM([<SOME_FIELD>]),12,3)
WHEN '<SOME_VAL_1>' THEN '<SOME_NEW_VAL_1>'
WHEN '<SOME_VAL_1>' THEN '<SOME_NEW_VAL_2>'
ELSE
'NA'
END
DATE([<SOME_DATETIME>])
Filters on Incoming Data can include formulas e.g.
MAX([<SOME_DATE_FIELD>]) < [Yesterday]
AND MIN([<SOME_DATE_FIELD>]) >= [FirstDayOfMonth]
Where some criteria are calculated fields
Use Data/Edit Relationships, Select Primary and Secondary Tables and Add Links as required. NB You can change the data in a field by making a calculated field and use the calculated field to make the join.
NB links show a red chain symbol when in use.
Drag Analysis Fields to Row And Columns and drop value field in Marks and set value to Text (and Marks to Text if required).
If you want to use most of the measures Drag Required Fields into Rows And Cols if desired then drag "Measure Names" into Rows or Columns as desired then drop "Measure Values" into Marks. Set Type to Text and remove non required items. NB this can be done in the filter which will appear.
IF [<SOME_FIELD_1>] = '<SOME_STRING>' AND [<SOME_FIELD_2>] = [<SOME_DATE>] THEN
[<SOME_FIELD_X>] * 100
ELSE
0
END
For example with Date as X/base parameter:
Drag Date into Columns. Change to (Exact Date)
Drag "Measure Values" into Rows
Remove unwanted items in Filters Card.
To Color: Click icon next to Measure Names in Marks Card and choose color, click large color button in Marks to change colors.
To Mark End of Line with data value right clik on node and select Mark Label/Always Show
Click Header To Change
Axis: Right click on Axis and Edit Axis
Include a second Axis: Drag Data For Second Axis to Rows, Click on its tab in the rows just created and select Dual Axis. Change Axis scale/color etc to suit.
Right click in Measures Area (bottom left) and click Create Parameter. Name New Parameter in Pop Up Select Type. etc Use LIST or RANGE if required and ADD Data Direct From Field or Paste in Right click on new parameter and Show Parameter Control
If using for selection drag the selection field into the Filters and select Condition/By Formula and enter [Field Name]=[Parameter Name] (You may need to do this twice for both joined fields where there is a join)
RC = Right Click, LC = Left Click etc.
• Show Me - Select Fields with ctrl + (click on field) then select show me
• Devise Specific - Toggle on/off with Device Preview
○ Select Phone/Tablet etc. click "Add <Device> Layout"
○ Format - once added wont change other views
○ Use initial dashboard as a template as only items on here can be used in device dashboards
• Dual Axis Graph
○ Two Fields
§ Drag field to cols (X axis)
§ Drag two fields to rows
§ Right click on rows and select dual axis
§ Right click on axis and select Synchronise
○ Multiple
• Drag field to cols for (X axis)
• Drag Field to rows for line/bar etc.
• Drag Field to left of graph till two bars || sign visible and drop
• Continue for as many lines/bars as required
• Drag Field to rows for new graph type (e.g. line if bar) or vice versa etc.
• Change new field to desired graph type
• Right click on left axis of bottom graph and choose dual axis
• Swap item positions in row shelves to move forward or back like z-index
• Set axis as desired
• Table means the same as crosstab or pivot
○ Use measure names and drag to centre.
• Hierarchy - for auto levels +/- ( duplicate a field in the hierarcy to use without the drill down option )
• Formatting can Copy from a Worksheet tab to another Worksheet tab (only copies formats for items in format Tab (Pane on Left) )
• Tooltip
○ Show Graph/Table in tooltip - Insert Sheet into tooltip to show mini graph etc.
§ Option use entire view if to big or change default size from 300*300
○ <ATTR(Field1)><ATTR(Field2)> If these strings <ATTR(Field1)> and <ATTR(Field2)> etc. are colored differently and are F1/F2 are calculations such that others evaluate to "" only the remaining one will display and be in the set color. E.g. their could be three evaluating to Reg Green and Amber.
• Sorting - Use
○ Axis buttons or
○ Manual - drag to required position
○ Click on pill in row/col shelf
○ Nested sort use axis button
• Groups - for a lot of small items they can be changed to just one category e.g. other
○ Right click dimension and Create/Group (creates new pill with the grouping in it)
○ OR select multiple rows in result and right click group
○ Include Other Option - Right click on pill with group select "include other" - switches non grouped into one category - Other
• Sets - Use sets to highlight specific items, -
○ sets can be combined inclusive/exclusive etc. e.g. by dropping on color in marks card to show in/out (i.e. IN/OUT of set)
• Set Actions
○ Select Field for Set RC
○ Create/Set options
§ Change Name and OK
○ Worksheet menu/Actions /Add/Change Set Values
§ Select Name/Where its applied and invoke method plus target set
○ Use By dropping on say color in marks or adding to formula
○ Actions in tooltips set by action not tooltip editor
• Level of Detail LOD - Select Fields with ctrl + (click on field) then create calculation (Not Available!!!!)
• Filters
○ Use ALL (allows new items to be auto included in the filter!!)
○ Different for Measure/Dimension
○ Formula Like SQL Having Clause
○ Dates have some presets
§ Last X years etc
○ Interactive
§ Have option for where they are used click ^ (C^)
§ Customise (include search/All etc)
§ Only Relevant (pre filtered excluded) or all option
○ Individual Record Vs Category filtering
§ Drag val e.g. profit to filters choose all to filter at record level or sum to filter at summary level
○ Context filters - these are applied first - efficiency?
• Discrete will create chunks e.g. year/qtr , continuous would be datetime
• Parameters
○ Use in formula e.g. Drilling on A crosstab example
○ Use in
• Dashboard containers (Objects Vert/Horiz) resize where there is less/more data to show