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
Ekaterina
Regular Visitor

IF condition

Hello,

 

could anyone tell me what is wrong with the following statement:

 

Column = IF Query[CR] = NaN then 0 else Query1[CR]

 

Thank you,

Ekaterina

5 REPLIES 5
MarcelBeug
Community Champion
Community Champion

= NaN won't work either in Power Query.

 

Working example query:

 

let
    Source = Table.FromList({1,#nan,2}, Splitter.SplitByNothing(), {"CR"}, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if Number.IsNaN([CR]) then 0 else [CR])
in
    #"Added Custom"

 

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

Hi @Ekaterina

 

Please replace "IF" with "if" (Power Query is case sensitive)

and Query[CR] with [CR].

 

 

@Anonymous well I select Query1[CR] as Power BI advices me in the bar so it knows from which query am I selecting CR. I have tried to replaced IF for if and tried both without Query1 and with it, but it returns me an error anyway. It says that ''the syntax for ´then´ is incorrect. (DAX(IF (Query1[CR] = NaN then 0 else Query1[CR]))).''

@Ekaterina

 

@MarcelBeug's reply should work for Power Query.

For DAX you can try

Column = IF(Query[CR]="NaN","0",Query[CR])

or

Column 2 = IF(ISBLANK(Query[CR]),"0",Query[CR])

 

 

Anonymous
Not applicable

Your Query seems to be a DAX Query..

 

@MarcelBeugand I posted you Power Query solutions (I have to admit, that only @MarcelBeug solution works, as I've overlooked the NaN issue....)..

 

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.