Forum Discussion
tamerj1
4 years agoCommunity Champion
REPLACE Function Returning Unexpected Results
AlbertoFerrari marcorusso and Comunity This is my first question in the Power Bi Comunity and I realy need your help. Any input would be highly appreciated. Usually I prefer to search, study and...
- 4 years ago
tamerj1 so, becasue until someone else will say otherwise, you found a bug 🙂
In the mean time, I just jumped over it and solved it in another way (I'm adding the DAX Query):EVALUATE VAR _CurrentTitle = SELECTCOLUMNS ( FILTER ('Table', 'Table'[Title] = "set field title case" ), "@Title", [Title] ) VAR _Length = LEN ( _CurrentTitle ) VAR T1 = GENERATESERIES ( 1, _Length, 1 ) VAR T2 = ADDCOLUMNS ( T1, "@Title", _CurrentTitle, "@SapceLocation", FIND ( " ", _CurrentTitle, [Value], BLANK ( ) ) ) VAR T3 = FILTER ( T2, [Value] = 1 || [@SapceLocation] = [Value] ) VAR T4 = ADDCOLUMNS ( T3, "@LetterLocation", IF ( [Value] = 1, 1, [Value] + 1 ) ) VAR T5 = ADDCOLUMNS ( T4, "@FirstLetter", MID ( [@Title], [@LetterLocation], 1 ) ) VAR T6 = ADDCOLUMNS ( T5, "@CapitalLetter", UPPER ( [@FirstLetter] & "" ) ) VAR T7 = ADDCOLUMNS( T6, "@Extracted Letter", MID ( [@Title], [@LetterLocation], COALESCE( MINX( FILTER( T6, [@LetterLocation] > EARLIER([@LetterLocation]) ), VALUE([@LetterLocation]) ), _Length * 3 ) - [@LetterLocation] - 1 ) ) VAR T8 = ADDCOLUMNS ( T7, "@Extracted Letter Title Case", REPLACE ( [@Extracted Letter], 1, 1, [@CapitalLetter] ) ) VAR Result = { CONCATENATEX ( T8, [@Extracted Letter Title Case], " ", [@LetterLocation], ASC ) } RETURN Result
SpartaBI
4 years agoCommunity Champion
tamerj1 so, becasue until someone else will say otherwise, you found a bug 🙂
In the mean time, I just jumped over it and solved it in another way (I'm adding the DAX Query):
EVALUATE
VAR _CurrentTitle = SELECTCOLUMNS ( FILTER ('Table', 'Table'[Title] = "set field title case" ), "@Title", [Title] )
VAR _Length = LEN ( _CurrentTitle )
VAR T1 = GENERATESERIES ( 1, _Length, 1 )
VAR T2 = ADDCOLUMNS ( T1, "@Title", _CurrentTitle, "@SapceLocation", FIND ( " ", _CurrentTitle, [Value], BLANK ( ) ) )
VAR T3 = FILTER ( T2, [Value] = 1 || [@SapceLocation] = [Value] )
VAR T4 = ADDCOLUMNS ( T3, "@LetterLocation", IF ( [Value] = 1, 1, [Value] + 1 ) )
VAR T5 = ADDCOLUMNS ( T4, "@FirstLetter", MID ( [@Title], [@LetterLocation], 1 ) )
VAR T6 = ADDCOLUMNS ( T5, "@CapitalLetter", UPPER ( [@FirstLetter] & "" ) )
VAR T7 = ADDCOLUMNS(
T6,
"@Extracted Letter",
MID (
[@Title],
[@LetterLocation],
COALESCE(
MINX(
FILTER(
T6,
[@LetterLocation] > EARLIER([@LetterLocation])
),
VALUE([@LetterLocation])
),
_Length * 3
) - [@LetterLocation] - 1
)
)
VAR T8 = ADDCOLUMNS ( T7, "@Extracted Letter Title Case", REPLACE ( [@Extracted Letter], 1, 1, [@CapitalLetter] ) )
VAR Result =
{
CONCATENATEX (
T8,
[@Extracted Letter Title Case],
" ",
[@LetterLocation],
ASC
)
}
RETURN
Result