Switch Function page 78

This is a dedicated forum for people that have questions about the book Supercharge Power BI. In the event of errors in the book, the error information will be in this forum.
RichM
Posts: 8
Joined: Mon Oct 12, 2020 10:45 am

Switch Function page 78

Postby RichM » 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

RamanaV
Posts: 60
Joined: Thu Oct 19, 2017 12:57 pm

Re: Switch Function page 78

Postby RamanaV » 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
Ramana Varanasi
Training and Office Manager
Excelerator BI Pty. Ltd.

RichM
Posts: 8
Joined: Mon Oct 12, 2020 10:45 am

Re: Switch Function page 78

Postby RichM » 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 :)

RichM
Posts: 8
Joined: Mon Oct 12, 2020 10:45 am

Re: Switch Function page 78

Postby RichM » 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.

RamanaV
Posts: 60
Joined: Thu Oct 19, 2017 12:57 pm

Re: Switch Function page 78

Postby RamanaV » 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 $]
)
Ramana Varanasi
Training and Office Manager
Excelerator BI Pty. Ltd.

RichM
Posts: 8
Joined: Mon Oct 12, 2020 10:45 am

Re: Switch Function page 78

Postby RichM » Tue Oct 13, 2020 11:20 pm

Excellent! I am still on chapter 13, so I shall learn that soon.

Thanks again


Return to “Help with the Book "Supercharge Power BI"”

Who is online

Users browsing this forum: No registered users and 0 guests

cron