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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

DAX Starts with "String" with a SWITCH statement

I currently have a SWITCH statement that looks for specific text and returns "Yes", "No" and this works fine. However, in addition to this I need to now add in another variable for:

 

Values that begin with "No harm sustained"......

 

I know I have to follow something like this:

 

if(left('Incidents'[Actual severity of impact],17) = "No harm sustained","Yes","No")

OR

VAR result1 = IF(LEFT(MIN(Incidents[Actual severity of impact],17) = "No harm sustained"), "Yes",resul

 

but I feel this will override my current measure.

 

My question is: is there a way to have my SWITCH statement (below) and also a LEFT statement for strings begining with "No harm sustained"?

 

 

Incidents[No harm / No Loss] =

VAR F_sp = SELECTEDVALUE('Reporting Period Filter'[RK_ReportingPeriod],MAX('Reporting Period Filter'[RK_ReportingPeriod]))
VAR F_rp = SELECTEDVALUE('ReportingPeriod'[RK_ReportingPeriod],F_sp)
VAR result = SWITCH(
SELECTEDVALUE('Incidents'[Actual severity of impact]),
"Air quality Monitoring not in line but no harm", "Yes",
"Breach of soil management requirements not resulting in damage", "Yes",
"No"
)

RETURN CALCULATE(result, KEEPFILTERS(ReportingPeriod[RK_ReportingPeriod] <= F_sp ), KEEPFILTERS(ReportingPeriod[RK_ReportingPeriod] = F_rp ))

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

 

VAR result = SWITCH(TRUE()
SELECTEDVALUE('Incidents'[Actual severity of impact])="Air quality Monitoring not in line but no harm", "Yes",
SELECTEDVALUE('Incidents'[Actual severity of impact])="Breach of soil management requirements not resulting in damage", "Yes",
SEARCH("No harm sustained", SELECTEDVALUE('Incidents'[Actual severity of impact]),1,0)=1,"Yes",
"No"
)

 

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

 

VAR result = SWITCH(TRUE()
SELECTEDVALUE('Incidents'[Actual severity of impact])="Air quality Monitoring not in line but no harm", "Yes",
SELECTEDVALUE('Incidents'[Actual severity of impact])="Breach of soil management requirements not resulting in damage", "Yes",
SEARCH("No harm sustained", SELECTEDVALUE('Incidents'[Actual severity of impact]),1,0)=1,"Yes",
"No"
)

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors