Forum Discussion
ArchStanton
Power Participant
10 months agoIF Statement or Switch
I've read that Switch statements are more efficient and less costly than IF statements so I'm trying to convert this code to Switch but I'm not sure how I can avoid the IF at the beginning? ...
- 10 months ago
Days to Validation Bins = //Try this VAR _Created = 'Cases'[Created On] VAR _State = 'Cases'[statecode] VAR _Days = 'Cases'[Days to Validation] RETURN SWITCH( TRUE(), AND(_Created < DATE(2020,4,1), OR(_State = "Resolved", _State = "2")), BLANK(), ISBLANK(_Days), BLANK(), _Days <= 30, "0-1 Mth", _Days <= 60, "1-2 Mths", _Days <= 90, "2-3 Mths", "Older" )
mh2587
Super User
10 months agoDays to Validation Bins = //Try this
VAR _Created = 'Cases'[Created On]
VAR _State = 'Cases'[statecode]
VAR _Days = 'Cases'[Days to Validation]
RETURN
SWITCH(
TRUE(),
AND(_Created < DATE(2020,4,1), OR(_State = "Resolved", _State = "2")), BLANK(),
ISBLANK(_Days), BLANK(),
_Days <= 30, "0-1 Mth",
_Days <= 60, "1-2 Mths",
_Days <= 90, "2-3 Mths",
"Older"
)