Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
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?
Solved! Go to Solution.
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"
)
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"
)
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
| User | Count |
|---|---|
| 50 | |
| 43 | |
| 36 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 139 | |
| 129 | |
| 61 | |
| 59 | |
| 57 |