cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lukaspowerbi Regular Visitor
Regular Visitor

SQL CASE Statement to column using DAX

I have a sql case statement that I would like to translate into DAX. 

 

CASE WHEN mem_type LIKE '%full%' AND mem_council = 'Council' THEN 'Full on Council' 

         WHEN mem_type LIKE '%full%'  THEN 'Full' 

         WHEN mem_type LIKE '%Under%'  THEN 'Under 35' 

         END as 'Mem_Group'

Is that possible? 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
yash1105 Member
Member

Re: SQL CASE Statement to column using DAX

SWITCH(
 TRUE()
, AND( SEARCH ( "Full", mem_type, 1, 0 ) > 0, mem_council = "Council" ), "Full on Council"

, SEARCH ( "Full", mem_type, 1, 0 ) > 0, "Full"

, SEARCH ( "Under", mem_type, 1, 0 ) > 0, "Under 35"

, "Mem_Group"

)

View solution in original post

2 REPLIES 2
Highlighted
Anonymous
Not applicable

Re: SQL CASE Statement to column using DAX

@lukaspowerbi

 

The SWITCH function is very similar to a SQL CASE statement. Check out the documentation here:

 

https://msdn.microsoft.com/en-us/query-bi/dax/switch-function-dax

 

The syntax will be something like:

 

Column =
SWITCH(
   TRUE(),
   Case1,Value1,
   Case2,Value2,
   [Optional Default Value if no conditions are met]
)

Hope this helps,

Parker

yash1105 Member
Member

Re: SQL CASE Statement to column using DAX

SWITCH(
 TRUE()
, AND( SEARCH ( "Full", mem_type, 1, 0 ) > 0, mem_council = "Council" ), "Full on Council"

, SEARCH ( "Full", mem_type, 1, 0 ) > 0, "Full"

, SEARCH ( "Under", mem_type, 1, 0 ) > 0, "Under 35"

, "Mem_Group"

)

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 217 members 1,751 guests
Please welcome our newest community members: