# If Function in Power Query and blank Cells



## DrDebit

In "M," how do I write an If function with a blank cell:

=if [Country] = "" then [Location] else [Country]

It is not working...probably having to do with testing if a cell is blank.

Please help.

Thank you!


----------



## MarcelBeug

Replace "" with null: =if [Country] = null then [Location] else [Country]


----------



## robintax

Use this code
=if [Country] = null then [Location] else [Country]


----------



## MarcelBeug

Why repeat the same answer?


----------



## DrDebit

Thank you!


----------



## martinhd53

Came across this issue when dealing with values as numeric.  Used the M function Type.IsNullable() and this worked.









						Type.IsNullable - PowerQuery M
					

Learn more about: Type.IsNullable



					docs.microsoft.com


----------

