Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lukaspowerbi
Helper II
Helper II

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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"

)

Anonymous
Not applicable

@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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.