Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all,
I have a new column definition [BedCount] written in DAX using several nested IF statements. I wanted to implement SWITCH to make things cleaner, but I couldn't wrap my head around how I would implement an AND in SWITCH. Any guideance on how to re-write this with SWITCH would be appreciated. I'd like to figure out how to do this as a Measure too, but was having trouble wrapping my head around the appropriate context. Having it added as a column "works" so the Measure piece is more about just getting better at Filter & Row context.
For more context, this column is currently added to the table 'prog_ProposeProg'. Basic star schema with the other two referenced tables having a direct relationship to 'prog_ProposeProgram'.
VAR SubCategory = RELATED(prog_CatSub[Name])
VAR Category = RELATED(prog_Categories[Name])
RETURN
IF(
AND(
CONTAINSSTRING(SubCategory, "Acute"),
CONTAINSSTRING(Category, "Inpatient")
),
prog_ProposeProgram[Target Area] / [Acute Inpatient],
IF(
AND(
CONTAINSSTRING(SubCategory, "Critical"),
CONTAINSSTRING(Category, "Inpatient")
),
prog_ProposeProgram[Target Area] / [Critical Bed],
IF(
AND(
CONTAINSSTRING(SubCategory, "Rehab"),
CONTAINSSTRING(Category, "Inpatient")
),
prog_ProposeProgram[Target Area] / [Rehab Bed],
BLANK()
)
)
)
Solved! Go to Solution.
Use SWITCH(TRUE()...) like:
SWITCH(TRUE(),
<condition1> && <condition2>,<result1>,
<condition3> && <condition4>,<result2>
<default result>
)
Use SWITCH(TRUE()...) like:
SWITCH(TRUE(),
<condition1> && <condition2>,<result1>,
<condition3> && <condition4>,<result2>
<default result>
)
duh! Thanks!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
15 | |
13 | |
11 | |
9 | |
8 |