Forum Discussion
delia
8 years agoFrequent Visitor
switch function
Hi, I have a switch function as follows: EstDesc = Switch ( TRUE (), WorkRequest[CurrentEstimate] = 97,"Small", WorkRequest[CurrentEstimate] = 497,"Medium", WorkRequest[CurrentEstimate] = 997,...
- 8 years ago
Hi delia,
That's a limitation of Direct Query. Please try it like below.
EstDesc = SWITCH ( TRUE (), WorkRequest[CurrentEstimate] = 97, "Small", WorkRequest[CurrentEstimate] = 497, "Medium", WorkRequest[CurrentEstimate] = 997, "Large", WorkRequest[CurrentEstimate] = 1997, "X-Large", "" & WorkRequest[CurrentEstimate] )Best Regards,
Dale
v-jiascu-msft
8 years agoMicrosoft Employee
Hi delia,
The WorkRequest[CurrentEstimate] must be a numerical column. The root cause is the type of the results are mismatched, Text and Numbers. You can modify it like below.
EstDesc =
SWITCH (
TRUE (),
WorkRequest[CurrentEstimate] = 97, "Small",
WorkRequest[CurrentEstimate] = 497, "Medium",
WorkRequest[CurrentEstimate] = 997, "Large",
WorkRequest[CurrentEstimate] = 1997, "X-Large",
FORMAT ( WorkRequest[CurrentEstimate], "" )
)
Best Regards,
Dale
- delia8 years agoFrequent Visitor
Hi v-jiascu-msft, you are correct that WorkRequest[CurrentEstimate] is a numerical column. I tried using the FORMAT function (thanks for the suggestion) but received this error:
Function FORMAT is not allowed as part of calculated column DAX expressions on DirectQuery models.
- v-jiascu-msft8 years agoMicrosoft Employee
Hi delia,
That's a limitation of Direct Query. Please try it like below.
EstDesc = SWITCH ( TRUE (), WorkRequest[CurrentEstimate] = 97, "Small", WorkRequest[CurrentEstimate] = 497, "Medium", WorkRequest[CurrentEstimate] = 997, "Large", WorkRequest[CurrentEstimate] = 1997, "X-Large", "" & WorkRequest[CurrentEstimate] )Best Regards,
Dale
- delia8 years agoFrequent Visitor
Awesome, that did it! Thanks Dale!!! :)