You are on page 1of 41

CORE CONCEPTS

PART 4
AGENDA • Filtering Data
– Writing Conditional Statements
– Boolean Logic
• Writing Formulas
– Formula Overview
– Basic Arithmetic
– Null, Zero, and Empty
– Conditional Statements
– String Expressions
– Multi-Row Formula
• Workflow Documentation
FILTERI N G
DATA
FILTERING DATA
Writing Conditional Statements
FILTER TOOL CONDITIONAL
STATEMENTS
• Basic Filter
– Tests for a single condition
– Writes the Expression for you

• Custom Filter
– Check for more complex conditions
– Check for multiple conditions
FILTER SYNTAX
Variable <<operator>> Value

[SCORE
]
FILTER SYNTAX
TEXT & NUMBERS

• Text – in QUOTES
[STATE]= “California”

• Numbers (no quotes)


[SCORE] >= 50

** Data type of variable must match type of value you are


checking against.
FILTERING DATA
Boolean Logic – Combining Multiple Conditions
VISUALIZING “OR”

True

[COLOR]=“BLUE” FALSE
TRUE

OR

[COLOR]=“YELLOW” FALSE
TRUE False
VISUALIZING “AND”

True

[NUMBER]>=2 FALSE
TRUE

AND

[NUMBER]<=5
TRUE
FALSE False
CUSTOM FILTER COMBINING
STATEMENTS

• Parenthesis Group Statements.


• Use AND/OR to combine groups.

Example: Find all the blue and yellow


shirts with numbers 2-5:

([COLOR] = “blue” OR [COLOR] = “yellow”)


AND
([NUMBER] >=2 AND [NUMBER] <= 5)
CUSTOM FILTER COMBINING
STATEMENTS
Example: Find all the blue and yellow shirts with numbers 2-5:
([COLOR] = “blue” OR [COLOR] = “yellow”) AND ([NUMBER] >=2 AND [NUMBER] <=5)

What shirts are true for


both statements?
KNOWLEDGE IN ACTION 1
INSTRUCTIONS R E S U LT S

• Limit records by Countr y –


only Canada and USA records
should remain

EXERCISE 13
FORMULAS
FORMULAS
Formula Overview
FORMULA INTRO

• Output Field
• Tabs
– Variables
– Functions
– Saved Expressions
• Expression
• Data Preview

16
OUTPUT COLUMN

• Output Field
– Select ‘Add Column’ for new field
• Type New Column Name
• Choose Data Type and Size
– Select existing column name to update
the field
• Not possible to change data type for
existing column in Formula – add select
before or after to update.

17
FUNCTIONS

• Organized by Category
• Hover over the function to see
brief explanation
• Go to ‘Help’ documentation
for detailed explanation and
examples

18
FORMULAS
Basic Arithmetic
BASIC ARITHMETIC

• Insert or type the name of variables


• Combine with one of the operators
below:
– Addition +
– Subtraction –
– Multiplication *
– Division /
ADDING DATA IN
SAME ROW

• Select the fields


by name
• Use the plus
operator “+” to
add the fields
together

21
SUBTRACTING DATA IN
SAME ROW

• Select the field by name


• Use the minus operator
“-” to subtract and find
the difference

22
FORMULAS
Null, Zero, and Empty
NULL, ZERO, EMPTY -
WHAT’S THE DIFFERENCE?

Value Insert Test

Null null() isnull([Field1])

Empty “” isempty([Field2])

Zero 0 [Field3] = 0
FORMULAS
Conditional Expressions
CONDITIONAL EXPRESSIONS
IN FORMULAS
Example: Using the shirts table insert a price
field.
Blue shirts are $5.00 and all other shirts are $2.50

IF [COLOR]= “blue”
THEN 5.00
ELSE 2.50
ENDIF

IF c // conditional statement
THEN t // action for true
ELSE f // action for everything not true
ENDIF

26
KNOWLEDGE IN ACTION 2
INSTRUCTIONS R E S U LT S

• Update Retur ns Column


• If returns is Null, then set to zero. Use the
formula tool
• C r e a t e To t a l S a l e s C o l u m n
• Sum Beauty Sales, Clothing Sales and Home
Décor Sales
• Create Net Sales Column
• Subtract Returns from Total Sales to obtain
Net Sales

EXERCISE 27
FORMULAS
String Expressions
UNDERSTANDING STRINGS
AND POSITION

Word Position WELCOME TO CLASS


0 1 2

Letter Position WELCOME TO CLASS


0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

29
UNDERSTANDING STRINGS
AND POSITION

• String Functions: Position


• GetWord([field],3) Result: “Alteryx”
Word Position 0 1 2 3
D a t a B l e n d i n g w i t h A l t e r y x

• FindString([field], “l”) Result: 6


Character Position 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
D a t a B l e n d i n g w i t h A l t e r y x

30
UNDERSTANDING STRINGS
AND LENGTH

Word Length WELCOME TO CLASS


1 2 3

Letter Length WELCOME TO CLASS


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

31
UNDERSTANDING STRINGS
AND LENGTH

• String Functions: Length


• Left([Field], 4) Result: “Data”
Character Position 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Character Length 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
D a t a B l e n d i n g w i t h A l t e r y x

• Right([Field], 2) Result: “yx”


Character Position 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Character Length 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
D a t a B l e n d i n g w i t h A l t e r y x

32
KNOWLEDGE IN ACTION 3
INSTRUCTIONS R E S U LT S

• C r e a t e Ye a r C o l u m n
• Use ‘Period’ field to derive year
• Create Quar ter Column
• Use ‘Period’ field to derive Quarter column

EXERCISE 33
FORMULAS
Multi-Row Formulas
MULTI-ROW FORMULA INTRO

• Field selection (New or Modify)


• Number of rows available in
expression
• Values for Rows that don’t Exist
• Group by (Optional)
• Variables
– Row-n: Field_Name: n rows above the
current row
– Field_Name: Row the data is being
created in (current row)
– Row+n: Field_Name : n rows below the
current row
VISUALIZING
MULTI-ROW FORMULAS
Goal: Rank stores for each month using multi-formula tool
Group by: Month
Values that Don’t Exist: 0
Logic: [Row-1:Store_Rank]+1
Store_Name Month Sales Store_Rank
Row-1 A November [0]
600
Active Row B November 387 1 [Row-1:Store_Rank]+1 → 0+1 → 1
Row+1 C November 562 2 [Row-1:Store_Rank]+1 → 1+1 → 2
A December 497 3 [Row-1:Store_Rank]+1 → 2+1 → 3
B December 503
[0]
1 [Row-1:Store_Rank]+1 → 0+1 → 1
2 [Row-1:Store_Rank]+1 → 1+1 → 2
[0]
KNOWLEDGE IN ACTION
INSTRUCTIONS R E S U LT S
• S o r t r e c o r d s b y Ye a r a n d
Quar ter in Ascending Order

• C a l c u l at e Q u a r t e r ove r
Quar ter percent change in Net
Sales by Countr y and Re gion
• (previous quarter – current quarter)/previous
quarter *100

EXERCISE 37
WORKFLOW
DOCUMENTATION
TOOL CONTAINER

• Organize your workflow into


logical groups
• Name each container to you can
easily find it later
– Pro Tip: Right-click and zoom to
container
• Collapse for easier viewing and
arranging of your workflow
• Disable containers to prevent its
contents from running
TOOL ANNOTATION

• Click the Annotation icon in the


left-side nav of configuration
window
• Enter a custom tool name to easily
navigate to the desired tool and
identify results messages
• Add an annotation to document
each step in the process
COMMENT

• Add comment tools to include


images and text on the canvas

• Pro Tip - Add multiple comment


tools to a tool container to easily
collapse and expand workflow
documentation

You might also like