0
0
Tableaubi_tool~10 mins

Difference and percent difference in Tableau - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate the difference between sales of the current and previous month.

Tableau
SUM([Sales]) - LOOKUP(SUM([Sales]), [1])
Drag options to blanks, or click blank then click option'
A-1
B0
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 instead of -1 as offset.
Using 0 which returns the current row value.
Confusing the direction of offset.
2fill in blank
medium

Complete the code to calculate the percent difference between sales of the current and previous month.

Tableau
(SUM([Sales]) - LOOKUP(SUM([Sales]), [1])) / ABS(LOOKUP(SUM([Sales]), [1]))
Drag options to blanks, or click blank then click option'
A1
B0
C-1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 instead of -1 as offset.
Dividing by current sales instead of previous sales.
Not using ABS which avoids division by negative.
3fill in blank
hard

Fix the error in the calculation to correctly compute percent difference in sales.

Tableau
(SUM([Sales]) - LOOKUP(SUM([Sales]), [1])) / LOOKUP(SUM([Sales]), [1])
Drag options to blanks, or click blank then click option'
A0
B1
CABS
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using positive offset which looks forward.
Using 0 which looks at current row.
Using ABS as offset which is invalid.
4fill in blank
hard

Fill both blanks to calculate the difference and percent difference between current and previous sales.

Tableau
Difference: SUM([Sales]) - LOOKUP(SUM([Sales]), [1])
Percent Difference: (SUM([Sales]) - LOOKUP(SUM([Sales]), [2])) / ABS(LOOKUP(SUM([Sales]), [2]))
Drag options to blanks, or click blank then click option'
A-1
B1
C0
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using different offsets for difference and percent difference.
Using positive offsets which look forward.
Using 0 which refers to current row.
5fill in blank
hard

Fill all three blanks to create a calculated field that returns percent difference formatted as a percentage string.

Tableau
ROUND(((SUM([Sales]) - LOOKUP(SUM([Sales]), [1])) / ABS(LOOKUP(SUM([Sales]), [2]))) * 100, [3]) + "%"
Drag options to blanks, or click blank then click option'
A-1
B0
C2
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or positive offsets which refer to current or next rows.
Not rounding or rounding to wrong decimal places.
Forgetting to multiply by 100 to get percentage.