cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dorothybl Frequent Visitor
Frequent Visitor

replace null values with content from another column based on condition

I have 20 million rows loaded. I want to replace null values from Column B. The value to be replaced will depends on what value is indicated on the column a.

 

Example:

For null values,

 

1 = W

4 = E

 

and so on..

 

2019-01-17_11-08-56.png


Please take note that null values are many. And the null values is not limited to two only. 

 

Just new to power bi desktop. please guide me. How should I do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
v-jiascu-msft Super Contributor
Super Contributor

Re: replace null values with content from another column based on condition

Hi @dorothybl,

 

Did you get any error messages? Or it returns wrong results? 

Maybe this one.

Result_Column =
IF (
    [Column B] = blank(),
    LOOKUPVALUE (
        'FixTable'[Letter],
        'FixTable'[Number], [Column A]
    ),
    [Column B]
)

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Super User
Super User

Re: replace null values with content from another column based on condition

Hi,

 

Create a lookup table and then join your existing Table with the look up Table.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
dorothybl Frequent Visitor
Frequent Visitor

Re: replace null values with content from another column based on condition

apologies but i cannot figure out how should i make a look up table for this.

i have 20 millions rows.

Super User
Super User

Re: replace null values with content from another column based on condition

Hi,

 

Since there are multiple null values, you will have to tell the software what should go in place of each such cell.  So there will have to be an input table of 2 columns with column 1 values from your existing table.  The second column should be the result you want.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-jiascu-msft Super Contributor
Super Contributor

Re: replace null values with content from another column based on condition

Hi @dorothybl,

 

Where are all the replacements? In other words, where is "1 = W 4 = E" from? It could be like this one.

 

Result_Column =
IF (
    ISBLANK ( [Column B] ),
    LOOKUPVALUE (
        'replacementsTable'[result],
        'replacementsTable'[Column A], [Column A]
    ),
    [Column B]
)

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
dorothybl Frequent Visitor
Frequent Visitor

Re: replace null values with content from another column based on condition

Hi @v-jiascu-msft

 

it will come from a separate table called "FixTable" and here is the sample data inside it. Data in the "FixTable" are only those numbers with blank letters.

 

2019-01-18_14-19-40.jpg

 

I tried using your code but it did not work. can you check what was wrong with it?

 

Result_Column =
IF (
    ISBLANK ( [Column B] ),
    LOOKUPVALUE (
        'FixTable'[Letter],
        'FixTable'[Number], [Column A]
    ),
    [Column B]
)
Highlighted
v-jiascu-msft Super Contributor
Super Contributor

Re: replace null values with content from another column based on condition

Hi @dorothybl,

 

Did you get any error messages? Or it returns wrong results? 

Maybe this one.

Result_Column =
IF (
    [Column B] = blank(),
    LOOKUPVALUE (
        'FixTable'[Letter],
        'FixTable'[Number], [Column A]
    ),
    [Column B]
)

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

dorothybl Frequent Visitor
Frequent Visitor

Re: replace null values with content from another column based on condition

hey it works! thanks @v-jiascu-msft

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 388 members 3,452 guests
Please welcome our newest community members: