Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
AliceW
Power Participant
Power Participant

IF / AND / NOT in Power Query M

Hi all,

Could anybody please convert this DAX formula in M for me? I'm stuck..

Amount =
if(
And(
Opp[Model]="Ren",
not(Opp[Type]="Ma")
),
Opp[Up],
Opp[AC]
)
3 ACCEPTED SOLUTIONS
nandukrishnavs
Community Champion
Community Champion

@AliceW 

 

Try this 

if ([Model] = "Ren") and ([Type] <>"Ma") then [Up] else [Ac]

PowerQuery is case sensitive, so use small letters only with if, else, then.



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

View solution in original post

AllisonKennedy
Community Champion
Community Champion

You can start by adding a Conditional Column in Power Query with just one of the conditions. 

 

To add a second condition, edit the formula in the formula bar by using the word 'and' as in the formula below:

 

=if [Model] = "Ren" and [Type]<>"Ma" then [Up] else [AC]

 

Or, just add a new custom column and paste that formula above into the formula box for the column. Spelling really counts with the column names, so make sure you get that right. 🙂 

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

@AliceW 

 

You have to mention the column name along with # symbol.

example [Sales$] ==> [#"Sales$"]



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 


Regards,
Nandu Krishna

View solution in original post

6 REPLIES 6
AllisonKennedy
Community Champion
Community Champion

You can start by adding a Conditional Column in Power Query with just one of the conditions. 

 

To add a second condition, edit the formula in the formula bar by using the word 'and' as in the formula below:

 

=if [Model] = "Ren" and [Type]<>"Ma" then [Up] else [AC]

 

Or, just add a new custom column and paste that formula above into the formula box for the column. Spelling really counts with the column names, so make sure you get that right. 🙂 

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

nandukrishnavs
Community Champion
Community Champion

@AliceW 

 

Try this 

if ([Model] = "Ren") and ([Type] <>"Ma") then [Up] else [Ac]

PowerQuery is case sensitive, so use small letters only with if, else, then.



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

Thank you so much, Nandu! It works!

Follow up question though 🙂 It doesn't allow me to enter columns with a symbol in the name (like $) in the 'then' and 'else' statements. Any idea why?

Thanks again!

@AliceW 

 

You have to mention the column name along with # symbol.

example [Sales$] ==> [#"Sales$"]



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 


Regards,
Nandu Krishna

Have you tried using the insert column wizard in the Power Query or are you typing the column name yourself? With special characters you will need special syntax, so if you follow my original post instructions to add a new custom column and use the insert field box on the right, you should have more success. 

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Thank you, Allison, I did use the add Customer column. I ended up replacing the special characters in the column names, to avoid other people coming up with the same issue.

Interesting trick you've shown!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.