Forum Discussion
Anonymous
4 years agoNot applicable
How to add / Subtract Character for SUBSTRING - causing some data type issue wrong data type or has
Hi I want to Implement SUBSTRING in Power BI, From a blog where i got to know by using LEFT and RIGHT Text functions we can achive it, which i'm able to write DAX properly, After that i need to ...
- 4 years ago
Hi Anonymous ,
Because there are 0 values in the return value of your variable "Var Len_First = SEARCH("First",'Require Comment'[Note Comment],,0)", and the -1 will exist after subtracting 1. And using -1 as an argument in the function LEFT will result in an error.
Please try modifying the variable to the following formula.
Var In_Substring = LEFT ( RIGHT ( 'Require Comment'[Note Comment], TotalLenght ), IF ( Len_FirstCallback = 0, 0, Len_FirstCallback - 1 ) )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Samarth_18
Community Champion
4 years agoAnonymous Please try this:-
m =
VAR Len_First =
SEARCH ( "First", 'Require Comment'[Note Comment],, 0 )
VAR TotalLenght =
LEN ( 'Require Comment'[Note Comment] )
VAR Substring1 =
IF (
Len_First <> blank,
LEFT (
RIGHT ( 'Require Comment'[Note Comment], TotalLenght ),
INT ( Len_First ) - 1
)
)
RETURN
Substring1Anonymous
4 years agoNot applicable
- Samarth_184 years ago
Community Champion
Anonymous Seems now error is different so you can try this now:-
m = VAR Len_First = SEARCH ( "First", 'Require Comment'[Note Comment],1, 0 ) VAR TotalLenght = LEN ( 'Require Comment'[Note Comment] ) VAR Substring1 = IF ( Len_First <> blank, LEFT ( RIGHT ( 'Require Comment'[Note Comment], TotalLenght ), INT ( Len_First ) - 1 ) ) RETURN Substring1