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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
beccar_13
New Member

Custom Query IF statement

I am trying to write an IF statement in the edit query but am having no luck. Is this function available?

1 ACCEPTED SOLUTION

Neither link mentions what happens if you use and's and or's without parentheses, so here is a little teaser for you:

 

= if 1 < 2 and 1 < 2 or 1 > 2 and 1 > 2 then """or"" starts a new group" else """and"" starts a new group"
Specializing in Power Query Formula Language (M)

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

HI @beccar_13,

 

Perhaps you can take a look at following links to know more about if statement:

Power Query if Statements

The IF Function In Power Query

 

Regards,

Xiaoxin Sheng

Neither link mentions what happens if you use and's and or's without parentheses, so here is a little teaser for you:

 

= if 1 < 2 and 1 < 2 or 1 > 2 and 1 > 2 then """or"" starts a new group" else """and"" starts a new group"
Specializing in Power Query Formula Language (M)

Most definitely, in the Query Editor, you can do things like:

if ( [AMT] = 0 or [AMT] = null ) and [Units] = 0 then 0
else 1

 

or

 

if [Code] <> null and [Description] <> null then [Code]&": "&[Description]
else if [Code] <> null then [Code]

 

Hope this helps,

 

Thank you so much for your help! I really appreciate it!

And bear in mind that Power Query is case sensitive with all keywords in lowercase, so IF won't work,

Specializing in Power Query Formula Language (M)

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.