How to Write a Case Statement in Tableau

preview_player
Показать описание


In this example I have a map by region. I used a case statement to group each region into an area. I have Area 1 and area 2.

Let's start by dragging region to rows I'm gonna write a case statement to group each of these regions into an area. If I click create calculated field I'll call this area one the function is going to be This. case, in the variable you want to look at in this case it's region so case region then we're going to type as many when's as we need so when South then area one. When East then area one. West then area two and when Central then area two.

Case statements end with the word end.

Let's bring area onto row shelf so I can see that it worked. You can see that Central is area two East is area one . Let's turn this into a map by clicking show me and clicking the field map I can move area and region to detail and change these both to be color. I can show a map in Tableau.
Рекомендации по теме
Комментарии
Автор

thanks for the tip! Straight to the point.

dantheman-adadwithchores