Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Conditional import from Excel

Hi,

 

When importing data from an excel file, I need to substitute some values with alternative values form another column. Is there a possibility in PowerBI import to do this? 

1 ACCEPTED SOLUTION

@Anonymous ,

 

Ok. So there's two (similar) ways to do this:

 

1) Create a new column (easy):

Add a new custom column with the following code:

 

if [End Customer] = "Not Applicable" then [Purchasing channel] else [End Customer]

 

 

---OR---

 

2) Replace N/A values within the existing column (intermediate):

Find a 'Not Applicable' value in your [End Customer] column, right-click and hit Replace Values.

In the dialog, add any text as the Replace With value, then hit OK:

BA_Pete_1-1636723835955.png

You will see in your formula bar that it has generated this code:

 

= Table.ReplaceValue(previousStep,"Not Applicable","abc",Replacer.ReplaceText,{"End Customer"})

 

Now replace the "abc" section with 'each [Purchasing channel]'. It should look like this:

 

= Table.ReplaceValue(previousStep,"Not Applicable", each [Purchasing channel], Replacer.ReplaceText,{"End Customer"})

 

This gives the following output:

BA_Pete_2-1636724054357.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

This isn't something that can be done during the data import per se, but it can certainly be done before the data is applied to the data model for reporting.

 

The data flow in Power BI Desktop in its most basic form is:

 

Data Source (Excel in your case) >> Power Query (do transformations) >> Data Model (define relationships) >> Report (write measures and visualise data).

 

What you're describing would be a transformation step that would be done in Power Query.

 

If you need help doing this, post an example of your data in this thread with a detailed description of what you want done and expected end result.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Anonymous
Not applicable

Hi, Pete, pls check this sample data:

 

1. Incoming data shows that some POSs maybe resold to an end-customer companies:

 

item#Purchasing channelEnd Customer Sales volume
1Star Inc.Not Applicable100
2Cube Inc.PPM Co.20
3Alliance Co.ABC Inc.500
4Star Inc.PPM Co.50
5Star Inc.Not Applicable45
6Cube Inc.Not Applicable20
7Alliance Co.ABC Inc.500
8Alliance Co.ABC Inc.20
9Alliance Co.PPM Co.300
10Star Inc.Not Applicable45

 

2. after processing the highlighted items in red has to be substituted by the items in 2d column:

 

item#Purchasing channelEnd Customer Sales volume
1Star Inc.Star Inc.100
2Cube Inc.PPM Co.20
3Alliance Co.ABC Inc.500
4Star Inc.PPM Co.50
5Star Inc.Star Inc.45
6Cube Inc.Cube Inc.20
7Alliance Co.ABC Inc.500
8Alliance Co.ABC Inc.20
9Alliance Co.PPM Co.300
10Star Inc.Star Inc.45

@Anonymous ,

 

Ok. So there's two (similar) ways to do this:

 

1) Create a new column (easy):

Add a new custom column with the following code:

 

if [End Customer] = "Not Applicable" then [Purchasing channel] else [End Customer]

 

 

---OR---

 

2) Replace N/A values within the existing column (intermediate):

Find a 'Not Applicable' value in your [End Customer] column, right-click and hit Replace Values.

In the dialog, add any text as the Replace With value, then hit OK:

BA_Pete_1-1636723835955.png

You will see in your formula bar that it has generated this code:

 

= Table.ReplaceValue(previousStep,"Not Applicable","abc",Replacer.ReplaceText,{"End Customer"})

 

Now replace the "abc" section with 'each [Purchasing channel]'. It should look like this:

 

= Table.ReplaceValue(previousStep,"Not Applicable", each [Purchasing channel], Replacer.ReplaceText,{"End Customer"})

 

This gives the following output:

BA_Pete_2-1636724054357.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors