Forum Discussion

kasiaw29's avatar
kasiaw29
Resolver II
5 years ago
Solved

PowerBI equivalent to SQL like with substring

Hi community,

 

Looking to see if anyone has any dax advice. 

Looking for PowwerBI equivalent to ... case when project_id like '%X' then substr(project_id,0,lenght(project_id)-1) else project_id end

 

Many thanks 

  • Whenever asking about sql, please include a description of what the script does. 

     

    If I understood correctly, a dax calculated column could be something like:

    Trimmed ID =

    IF(

        RIGHT( [project_id], 1) = "X", 

        LEFT( [project_id], LEN([project_id]) - 1),

        [project_id]

2 Replies

  • Gabriel_Walkman's avatar
    Gabriel_Walkman
    Continued Contributor

    Whenever asking about sql, please include a description of what the script does. 

     

    If I understood correctly, a dax calculated column could be something like:

    Trimmed ID =

    IF(

        RIGHT( [project_id], 1) = "X", 

        LEFT( [project_id], LEN([project_id]) - 1),

        [project_id]

  • kasiaw29 you can use SEARCH DAX function

     

    Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.