Forum Discussion

cottrera's avatar
cottrera
Post Prodigy
4 years ago
Solved

Power Query IF Statement

Hi 

 

I have a table with the following columns Ref, VAT Code, VAT Amount, VAT Amount query119. The table is 100,000 rows long and will continue to grow. I need to create a custom column in power query with an IF Statement to do the following

 

IF VAT Code = F2 then VAT Amount Query 119 else VAT Amount

 

I have tried many different combinations but keep receiving an error

Journal RefVAT CodeVAT  AmountVAT Amount - Query 119
1084523D001313
1099880D0040
1033875F20247
1056924F2033
1071960F202438
1075097F20400
1075411F20400
1098041F3015
1109724F3031
1109728F3011
1101111F0204204
1104774F901061
1077322N00145
1071910N21977
1077211N2793286
1077322N21872
1118252NN040
1148406NN040
1077322P262145
1083805P21963974
1091893P2233613979
1094075P210582004
343434P3113113

 

thank you

 

Richard

6 Replies

  • cottrera ,

    Go to Power Query --> Add Column Menu --> Click on Conditional Column and fill like below:

     

     

    Or Else you can do it using DAX column like below:

    DAX Column = IF(Sheet2[VAT Code]="F2",(Sheet2[VAT Amount - Query 119]),(Sheet2[VAT  Amount]))
     
    • cottrera's avatar
      cottrera
      Post Prodigy

      Hi  Thank you for your response you suggestion worked perfectly. Unfortunatly someone answered before you and I marked them as resolved

      RIchard

  • Anonymous's avatar
    Anonymous
    Not applicable

    cottrera Add custom column with this code:

    if [VAT Code]="F2" then [#"VAT Amount"] else [#"VAT Amount - Query 119"]

    • cottrera's avatar
      cottrera
      Post Prodigy

      Hi Marik thank you for your quick response. I tried the customer column method but received and error

      So I then tried manikumar34 option.
      thank you anyway

    • cottrera's avatar
      cottrera
      Post Prodigy

      Thank you manikumar34 for your quick reponse. I always answer in order of who contacted me by date and time. Your option worked aso marked as solution

      Richard