Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

IF statement multiply value based on text in other column

Hi all,

 

I want to make an IF statement in Power Query that would multiply the number that I have in a column called ALG_Prijs, but it should only be multiplied when the a column named ALG_Detail contains the word "chair".

I have been trying for quite some time now, but I can't get it to work. 

Anyone have any ideas?

 

Thanks! 

  • Use following in a custom column where you will need to replace "Your number" appropriately. 

    = if Text.Contains([ALG_Detail],"chair",Comparer.OrdinalIgnoreCase) then [ALG_Prijs]*"Your number" else null

4 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Most Valuable Professional

    Use following in a custom column where you will need to replace "Your number" appropriately. 

    = if Text.Contains([ALG_Detail],"chair",Comparer.OrdinalIgnoreCase) then [ALG_Prijs]*"Your number" else null

    • Anonymous's avatar
      Anonymous
      Not applicable

      It seems to work, apart from the moment where it shows "Error" in the new column. Once I click on it, I get this message: Expression.Error: We cannot apply operator * to types Number and Text.

      • Vijay_A_Verma's avatar
        Vijay_A_Verma
        Most Valuable Professional

        Did you replace "Your number" with an approriate column or number? And also make sure that [ALG_Prijs] and "Your number" contains number only.

        If still the problem, please paste your query and some sample data here.