Power BI IF NULL then 0

In this Power Bi tutorial, we will learn what is Power BI If a null statement and how can we check the null value is presented in a column with examples. In addition, we will also learn to use the power query editor to check null values in Power BI. Moreover, we also cover the below headings:

  • Power BI if null then 0
  • Power BI if a null measure
  • Power BI if null then Blank
  • Power BI if null then else

Power BI if null statement

Power BI IF statement is a logical statement that checks a condition and returns the first value as True else it returns the second value as False.

The Power BI IF statement syntax:

IF(<logical_test>, <value_if_true>[, <value_if_false>])

In the following, we will see how to work with the Power BI IF statement null with different examples.

Power BI if null then 0

Let us see how to display the zero values for the null values using the Power Bi IF function in the Power BI report.

In this example, we will use the below Stocks table data as a data source, and if any of the rows presented null values then it displays 0 else it returns a blank value.

  • Log in to the Power Bi desktop and load data using the get data option. Once the data has been loaded, Click on the new column option under the modeling tab and apply the below-mentioned formula:
Text Null = IF(not(isblank(Stocks[Symbol])),BLANK(),"0") 

Where,

  1. Text Null = Newly calculated column
  2. Stocks = Table Name
  3. Symbol = Existing Column Name

In the below screenshot, we can see that if the Symbol column has null values then it returns the value as 0 else it returns a blank value based on the condition applied:

Power BI if null then 0
Power BI if null then 0

This is how to display the zero values for the null values using the Power Bi IF function in Power BI.

Power BI if a null measure

Let us see how to find the null value using the Power Bi DAX function in Power BI.

In this example, we will find the null values for the data below and if the selected column contains null values then we will display the null value else we will display the column value in the Table visual.

Power BI if null then 0 dax
Power BI if null then 0 dax

Log in to the Power Bi desktop and load data using the get data option. Once the data has been loaded, select the new measure option and use the below formula:

Table Measure = IF(SELECTEDVALUE(Stocks[Symbol])=BLANK()," Null Value",SELECTEDVALUE(Stocks[Symbol]))

Where,

  1. Table Measure = New Measure name
  2. SELECTEDVALUE = Function Name
  3. Stocks = Table Name
  4. Symbol = Column Name

Select the table visual from the visualization, drop the Stock name, Symbol, and the created measure value into the columns section as shown below:

Power BI if a null measure
Power BI if a null measure

The screenshot below displays the values in the table visual based on the condition applied. If the column has a null value then it returns a null value else the presented value in the column.

Power BI if a null measure example
Power BI if a null measure example

This is how to find the null value using the Power Bi DAX function in Power BI.

Power BI if null then Blank

Here we will see how can we find the null value using the Power Bi If function in Power BI.

In this example, we will find the null value for the stock shares column as highlighted below, if the stock has zero or null shares then it returns a blank value else it returns the stock shares value in matrix visual.

Power BI if null then Blank
Power BI if null then Blank

Open the Power Bi desktop and load data using the get data option. Once the data has been loaded, Click on the new measure option under the modeling tab and apply the below-mentioned formula:

Matrix Measure = IF(SELECTEDVALUE(Stocks[Shares])=BLANK(),"Blank",SELECTEDVALUE(Stocks[Shares]))

Where,

  1. Matrix Measure = New Measure name
  2. SELECTEDVALUE = Function Name
  3. Stocks = Table Name
  4. Shares= Column Name

Select the matrix visual from the visualization, drop the Stock name in the row section, shares the field, and the created measure value into the values section as shown below:

Example of Power BI if null then Blank
Example of Power BI if null then Blank

In the below screenshot, we can see that the matrix visually displays the result value based on the applied condition.

Power BI if null then Blank example
Power BI if null then Blank example

This is how to find the null value using the Power Bi If function in Power BI.

Read Power BI Merge Two Tables without Duplicates

Power BI if null then else

Here we will see how to check the null values using the Power Query editor in Power BI.

In this example, we will check the null value for the stock shares field, if any of the rows have null values then we will display the null value else it returns the stock shares value.

  • Load the data into the Power Bi desktop, and Select the Home tab -> to transform data option, It will automatically redirect to the Power Query editor.
  • select the Add Column-> Custom column in the power query editor. In the custom column pop-up window use the below formula and click the ok button.
if(([Shares])=null) then "Null Value" else[Shares]
Power BI if null then else
Power BI if null then else
  • In the below screenshot, we can see that the newly added custom column displays the value based on the condition applied.
  • If the Symbol column contains the text data type value then it returns the null value else it returns the stock shares value.
  • Click on Close & Apply under the home tab, so that the changes will be reflected on the Power Bi desktop.
= Table.AddColumn(#"Removed Columns2", "Custom", each if(([Shares])=null) then "Null Value" else[Shares])
Power BI if null then else example
Power BI if null then else example

This is how to check the null values using the Power Query editor in Power BI.

In this Power Bi tutorial, we have learned what is Power BI If a null statement and how can we check the null value is presented in a column with examples. In addition, we also learned to use the power query editor to check null values in Power BI. Moreover, we also covered the below headings:

  • Power BI if null then 0
  • Power BI if a null measure
  • Power BI if null then Blank
  • Power BI if null then else

You may like the following Power Bi tutorials:

>