Forum Discussion
rssilvaba
Resolver II
6 years agoMatching the last occurrence of string pattern with DAX
I am trying to get the text between following pattern with DAX: __ tjer 3(4x22) D __ ______ T__r RTY 15x48.8kg TY A_ PS: the underscore is just to hide the data, assume it is any character. I wo...
- 6 years ago
Hi rssilvaba ,
Last occurrence of "x" Column = FIND ( "@", SUBSTITUTE ( [Column1], "x", "@", LEN ( [Column1] ) - LEN ( SUBSTITUTE ( [Column1], "x", "" ) ) ) )Last occurrence of "x" Measure = FIND ( "@", SUBSTITUTE ( MAX ( 'Table'[Column1] ), "x", "@", LEN ( MAX ( 'Table'[Column1] ) ) - LEN ( SUBSTITUTE ( MAX ( 'Table'[Column1] ), "x", "" ) ) ) )Then, I can get the string before the last "x".
String before the last "x" = LEFT([Column1],[Last occurrence of "x" Column]-1)But currently I don't know how to get the last several numbers. Maybe you can try the method swise001 provided.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Icey
Community Support
6 years agoHi rssilvaba ,
Last occurrence of "x" Column =
FIND (
"@",
SUBSTITUTE (
[Column1],
"x",
"@",
LEN ( [Column1] ) - LEN ( SUBSTITUTE ( [Column1], "x", "" ) )
)
)
Last occurrence of "x" Measure =
FIND (
"@",
SUBSTITUTE (
MAX ( 'Table'[Column1] ),
"x",
"@",
LEN ( MAX ( 'Table'[Column1] ) )
- LEN ( SUBSTITUTE ( MAX ( 'Table'[Column1] ), "x", "" ) )
)
)
Then, I can get the string before the last "x".
String before the last "x" = LEFT([Column1],[Last occurrence of "x" Column]-1)
But currently I don't know how to get the last several numbers. Maybe you can try the method swise001 provided.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.