Page 1 of 1

### Switch Function page 78

Posted: Mon Oct 12, 2020 10:50 am
Hi - Attempting to follow along in the book and I am having trouble with the Switch function.

House Ownership = SWITCH(
'customers'[HouseOwnershipFlag],1, "owns their own house",0,"Doesn't own their own house", "unknown")

Intellisense isn't recognizing the "Customer[HouseOwnerFlag] column. (Or any of the other columns in that table)

Can anyone suggest why that might be? Thanks

Rich

### Re: Switch Function page 78

Posted: Mon Oct 12, 2020 12:53 pm
The formula is
House Ownership =
SWITCH(Customers[HouseOwnerFlag],
1,"Owns their house",
0,"Doesn't own their house",
"Unknown"
)
Please check that there are no typos in the formula.
Intellisense cannot point out typos

### Re: Switch Function page 78

Posted: Mon Oct 12, 2020 11:31 pm
Thanks Ramana for the reply. Intellesense still isn't seeing it.

I am only given options in Intellesense that are measures. Does Switch only work with Measures? Sorry for the Newbie questions

### Re: Switch Function page 78

Posted: Tue Oct 13, 2020 7:43 am
Silly me - I was trying to create a measure when I should have been creating a calculated column.

### Re: Switch Function page 78

Posted: Tue Oct 13, 2020 10:11 am
SWITCH function works for both measures and calculated columns.
The above example is for a calculated column using SWITCH function.
Here is an example of SWITCH function for a measure: (Chapter 17, Section Here’s How: Creating a Morphing Switch Measure
Measure to Display =
SWITCH([Selected Measure],
1,[Total Sales],
2,[Total Cost],
3,[Total Margin \$]
)

### Re: Switch Function page 78

Posted: Tue Oct 13, 2020 11:20 pm
Excellent! I am still on chapter 13, so I shall learn that soon.

Thanks again