見出し画像

How parameter actions work in 'Tableau 24 slide puzzle'

Let me explain how parameter actions work in the tableau workbook 'Tableau 24 slide puzzle'

The workbook is here.  (download available)

画像18


Data source is

画像2

[ID] means ID number of 24 tiles and blank area.
"P" means blank area.

24 images are used as 'shape' in this workbook.
The combinations of [ID] and tile shapes are as following.

画像3

Next, let me explain about the parameter {Order]
It is a strings parameter with 25 characters
Default value is "123456789ABCDEFGHIJKLMNOP"

This Parameter indicate how the tiles arranged in the puzzle.

画像4

If the [Parameter] is  "123456789ABCDEFGHIJKLMNOP"
the tiles are arranged as

画像5

So the entire image is

画像6

For example if [Parameter] is "H2EN36I4K5BGP1C9D8O7MLAFJ",
tiles are arranged as

画像7

so entire image is

画像8

Next, is about calculation fields.
These calculation fields are row level calculation. So they are calculated by each [ID].

1. [Position]
Position of each character of  [ID] in the parameter [Order]

画像10

2.[Row]
Row number of each tile in 5*5 matrix , calculated by [Position]

画像12

3.[Column]
Column number of each tile in 5*5 matrix , calculated by [Position]

画像13

4. [Blank Position]
Position of "P" in the parameter [Order]  ("P" means blank area in the 5*5 matrix)

画像11


5.[to change order]
This calculation field is a little bit complicated , but it is the key field for parameter actions.

This filed indicate "how the arrangement of tiles should change to" when each tile is clicked. 

For example , now the parameter [Order] is "123456789ABCDEFGHIJKLMNOP" 
("P" = blank area )
When you clicked tile "O", tile "O" will move to rightward and be swapped with "P".
So [Order] should become "123456789ABCDEFGHIJKLMNPO"

One more example , now the parameter [Order] is "123456789ABCDEFGHIJKLMNOP"
When you clicked tile "K" , tile "K" will move downward and be swapped with "P".
So [Order] should become "123456789ABCDEFGHIJPLMNOK"

In other words, each tile has the calculated characters that indicate "how the parameter [Order] should become" , when each tile is clicked.

This calculation field is 

画像9

First part
IF NOT([Column]=4) AND [Blank Position]=[Position]+1
THEN REPLACE([Order],[ID]+"P","P"+[ID])

It means that if the tile is not on the right edge and right side of the tile is ”P"=Blank , then swap [ID] and "P" in the parameter [Order]

2nd part
ELSEIF NOT([Column]=0) AND [Blank Position]=[Position]-1
THEN REPLACE([Order],"P"+[ID],[ID]+"P")

It means that if the tile is not on the left edge and left side of the tile is ”P"=Blank , then swap [ID] and "P" in the parameter [Order]

3rd part
ELSEIF NOT([Row]=4) AND [Blank Position]=[Position]+5
THEN

REPLACE(
Replace(
REPLACE(
REPLACE([Order],"P","Q"),
[ID],"R")
,"Q",[ID])
,"R","P")

It means that if the tile is not on the lower edge and lower side of the tile is ”P"=Blank , then swap [ID] and "P" in the parameter [Order].
For this calculation , at once , change "P" to "Q" and [ID] to "R"
then change "Q" to [ID] and "R" to "P".

4th part
ELSEIF NOT([Row]=0) AND [Blank Position]=[Position]-5
THEN

REPLACE(
Replace(
REPLACE(
REPLACE([Order],"P","Q"),
[ID],"R")
,"Q",[ID])
,"R","P")

It means that if the tile is not on the upper edge and upper side of the tile is ”P"=Blank , then swap [ID] and "P" in the parameter [Order].
For this calculation , at once , change "P" to "Q" and [ID] to "R"
then change "Q" to [ID] and "R" to "P".

Last part
ELSE [Order]
END

If there is not blank area around the tile, the arrangement will not change at all. So there is no change in the parameter [Order].


Then make a worksheet as below

画像14

画像15

with putting "to change order" on mark detail for parameter actions.

On the dashboard, set parameter action as below.

画像16

With this setting , when tiles are clicked , the parameter [Order] is changed by [to change order] of each tile.
These are explanation about parameter action in this workbook.

I explained focusing on parameter actions.
In actual workbook some more functions are added. 

画像18

This puzzle is not data visualization, but it contains huge possibility of parameter actions I think.

I hope this post would help you create interactive data visualization.

Thank you so much for reading.

PS.
My parameter action is inspired by
@datavizlinds  ’s tweet

&
@VizWizBI       's answer Viz

And thanks so much for
@lukestanke
's great tips




By ritz_Tableau
Tableau Zen Master | Tableau Public Ambassador |
Tableau Certified Professional | Data Saber
Twitter : @ritz_Tableau


この記事が気に入ったらサポートをしてみませんか?