Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Column with Power Query/ M

Hi, i have following Code:

 

But for some reason, the last Else doenst work.

 

Any ideas why?

 

Thanks!

  • Hey Anonymous 

     

    Your issue is with Text.StartsWith . When given a null value it returns null so PBI doesn't know what to do with this logical. You have to account for null too. Try:

    if [Priority] = null then null else
        if Text.StartsWith([#"Additional info:"]??"""CQN")
        or Text.StartsWith([#"Additional info:"]??"""FQN")
            then Text.BeforeDelimiter(Text.Start([#"Additional info:"], 12), ":")
        else [Priority]

     

    It should do the trick.



    Cheers

5 Replies

  • Smauro's avatar
    Smauro
    Solution Sage

    Hey Anonymous 

     

    Your issue is with Text.StartsWith . When given a null value it returns null so PBI doesn't know what to do with this logical. You have to account for null too. Try:

    if [Priority] = null then null else
        if Text.StartsWith([#"Additional info:"]??"""CQN")
        or Text.StartsWith([#"Additional info:"]??"""FQN")
            then Text.BeforeDelimiter(Text.Start([#"Additional info:"], 12), ":")
        else [Priority]

     

    It should do the trick.



    Cheers

  • AlB's avatar
    AlB
    Community Champion

    Hi Anonymous 

    What exactly is it that does not work? can you share the pbix?

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hey AlB ,

      Thats the result.

       

      In the line, where DoA is, is the Error.

       

       

       

  • AlB's avatar
    AlB
    Community Champion

    Anonymous 

    I need either the pbix file (or ine with dummy data thhat reproduces the error) or a complete explanation of the error messages that you get. Otherwise I cannot help.

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi AlB ,

       

      Thank you for the help!!