Forum Discussion
Anonymous
6 years agoNot applicable
switch
Hello, I would like to add a column to an existing table in the model but the error is below. Any suggestions please?: Function 'SWITCH' does not support comparing values of type Text with value...
- 6 years ago
Hi Anonymous
try CONVERT()
StartMonthDayKey = var _CalendarQuarterKey = LEFT(CONVERT('myDate'[CalendarQuarterKey], STRING), 4) RETURN SWITCH( 'myDate'[CalendarQuarterKey], 1, _CalendarQuarterKey & "0105"), 2, _CalendarQuarterKey & "0405"), 3, _CalendarQuarterKey & "0705"), 4, _CalendarQuarterKey & "1005") )
az38
6 years agoCommunity Champion
Hi Anonymous
try CONVERT()
StartMonthDayKey =
var _CalendarQuarterKey = LEFT(CONVERT('myDate'[CalendarQuarterKey], STRING), 4)
RETURN
SWITCH(
'myDate'[CalendarQuarterKey],
1, _CalendarQuarterKey & "0105"),
2, _CalendarQuarterKey & "0405"),
3, _CalendarQuarterKey & "0705"),
4, _CalendarQuarterKey & "1005")
)Anonymous
6 years agoNot applicable
, still getting error:
The syntax for ',' is incorrect. (DAX(var _CalendarQuarterKey = LEFT(CONVERT('Date'[Calendar Quarter Key], STRING), 4)RETURN SWITCH('Date'[CalendarQuarterKeyValue],1, _CalendarQuarterKey & "0105"),2, _CalendarQuarterKey & "0405"),3, _CalendarQuarterKey & "0705"),4, _CalendarQuarterKey & "1005")))).
- az386 years agoCommunity Champion
Anonymous
sorry, wrong parenthesys
StartMonthDayKey = var _CalendarQuarterKey = LEFT(CONVERT('myDate'[CalendarQuarterKey], STRING), 4) RETURN SWITCH( 'myDate'[CalendarQuarterKey], 1, _CalendarQuarterKey & "0105", 2, _CalendarQuarterKey & "0405", 3, _CalendarQuarterKey & "0705", 4, _CalendarQuarterKey & "1005" )