In this Power BI article, we will learn how to check if the text is null using the Power Query editor with examples. In addition, we also cover below mentioned points.
- Power query replaces null in all columns
- Power BI checks if the Text is null
- Power query replace null with column value
Check if the text is null in Power BI
Let us see how to check if the text is null using the Power BI if function in Power BI.
In this example, we will use the below Stocks table data as a data source to check if the text is null and then returns the true value or else a false value in Power BI.
- 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])),"No","Yes")
Where,
- Text Null = Newly calculated column
- Stocks = Table Name
- 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 true else it returns a false value based on the condition applied:
This is how to check if the text is null using the Power BI if function in Power BI.
Power query replaces null in all columns
Here we will see how we can replace null in all columns using the Power Query editor in Power BI.
In this example, we will use the Query editor to replace the null values in the columns using the replacement value option.
To achieve this follow the below steps:
- Open the Power Bi desktop and load the data into it, and under the Home, tab selects the transform data option as shown below: It will automatically redirect to the Power Query editor.
- Now in the power query editor, you can see that the column data presented in null values as highlighted below:
To replace all the null values in a column, right-click on the column and select replace values as shown below:
- In the Replace values popup window, enter the Value To find as null and replace with as empty which takes as null value.
- Click the ok button.
- In the below screenshot, you can see that the symbol column has been replaced with the null values as shown below:
- Click on Close & Apply under the home tab, so that the changes will be reflected on the Power Bi desktop.
= Table.ReplaceValue(#"Removed Columns1",null,"",Replacer.ReplaceValue,{"Symbol"})
This is how to replace null in all columns using the Power Query editor in Power BI.
Power query replace null with column value
Let us see how we can replace null values with column values using the Power Query editor in Power BI.
In this example, we will use the Query editor to add a custom column, if the column has null values replace it with another column value. For example, if the symbol column contains a null value then we will display the stock name column value.
- Load the data into the Power Bi desktop, and under the Home, tab selects the transform data it automatically redirects to the Power Query editor.
- In the Power Query editor, Add a custom column by selecting Add Column-> Custom column as highlighted below:
- In the custom column pop-up window, enter the new column name and add the below-mentioned formula and click on the ok button.
if([Symbol]=null)then [Stock Name] else [Symbol]
- 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 null value then it returns the stock name column value else it returns the default value.
- Click on Close & Apply under the home tab, so that the changes will be reflected on the Power Bi desktop.
= Table.AddColumn(#"Removed Columns1", "Replace Column Values", each if([Symbol]=null)then [Stock Name] else [Symbol])
This is how to replace null values with column values using the Power Query editor in Power BI.
In this Power BI article, we have learned how to check if the text is null using the Power Query editor with different examples. In addition, we also covered below mentioned points.
- Power query replaces null in all columns
- Power query replace null with column value
You may like the following Power BI tutorials:
- Power BI Measure If Text
- Power BI Conditional Formatting Based on Text
- Power BI Date Slicer By Month
- What if Parameter in Power BI
- Convert Text to Number in Power BI
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com