Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 ...
  • v-kkf-msft's avatar
    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.