Forum Discussion

EimearC's avatar
EimearC
Frequent Visitor
3 years ago
Solved

Expression Error assistance: We cannot convert the value xx to type Text

Hi there,

I am trying to do an IF statement where it checks if there is text within a cell, if thre is text then I need the cells concatenated, if there is no text then I need them to SUM. The SUM part works fine on its own but once I wrap the IF statement in there, then I get the above expression error, I'd be grateful if anyone would have a solution please? 

 

Adding custom column code: if not Text.Contains([Primary Motor], "x") or not Text.Contains([Secondary Motor], "x") then [Primary Motor] + [Secondary Motor] else Text.From([Primary Motor]) & ", " & Text.From([Secondary Motor])

 

 

 

Thank you so much

 

  • You could try something like: 

     

    if  [Primary Motor] is text and [Secondary Motor] is text then Text.Combine( {[Primary Motor], [Secondary Motor]}) else [Primary Motor] + [Secondary Motor]

     

    --------------------------------------------------

    @ me in replies or I'll lose your thread

     

    Master Power Query M? -> https://powerquery.how

    Read in-depth articles? -> BI Gorilla

    Youtube Channel: BI Gorilla

     

    If this post helps, then please consider accepting it as the solution to help other members find it more quickly.

3 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Most Valuable Professional

    Replace this part

    [Primary Motor] + [Secondary Motor] 

    With

    Number.From([Primary Motor])+Number.From([Secondary Motor])

  • You could try something like: 

     

    if  [Primary Motor] is text and [Secondary Motor] is text then Text.Combine( {[Primary Motor], [Secondary Motor]}) else [Primary Motor] + [Secondary Motor]

     

    --------------------------------------------------

    @ me in replies or I'll lose your thread

     

    Master Power Query M? -> https://powerquery.how

    Read in-depth articles? -> BI Gorilla

    Youtube Channel: BI Gorilla

     

    If this post helps, then please consider accepting it as the solution to help other members find it more quickly.

  • EimearC's avatar
    EimearC
    Frequent Visitor

    Hi Vijay, I received the same error when I attempted to use the Number.From but thank you so much for responding to me. 

    Rick, your solution worked perfectly, thank you both so much!