Forum Discussion
siyuri
3 years agoFrequent Visitor
Convert SQL LIKE "__1__" to DAX
Hello! Need your help 🙂 How do I write this sql expression: LIKE "__1__" in DAX? I'd Use MID(3,1) = 1, but I need exact two any characters after "1" as well and mid works from the left only? T...
- 3 years ago
Hi siyuri ,
I would do the following:
- find the position of "1"
- subtract 2 from the position of 1 as my starting point for MID
- then use 5 for the number of characters to extract two characters before and after "1" with "1" included in 5
So in DAX, I'd use this formula
= VAR PositionOf1 = FIND ( "1", 'Table'[Column], 1, BLANK () ) RETURN MID ( 'Table'[Column], PositionOf1 - 2, 5 )
danextian
Super User
3 years agoHi siyuri ,
I would do the following:
- find the position of "1"
- subtract 2 from the position of 1 as my starting point for MID
- then use 5 for the number of characters to extract two characters before and after "1" with "1" included in 5
So in DAX, I'd use this formula
=
VAR PositionOf1 =
FIND ( "1", 'Table'[Column], 1, BLANK () )
RETURN
MID ( 'Table'[Column], PositionOf1 - 2, 5 )
- siyuri3 years agoFrequent Visitor
wow...so there is really no straight forward way... Thank you for this solution!