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
theu1996
New Member

Adding a character to certain values in a column

Hi,

 

I have a list of machines and plants and in the Excel source, my machine column was saved as a number instead of text and a number of machines lost the 0 in front of their name. Is there a way to add this back to the machine names, either in a new column or the existing one? Or would a find and replace be the best option?

Below is an example of the data, but the list of machines that need to be fixed is much larger:

 

 

PlantMachine
17211
17306
170205A
210369B
65ASSEMBLY1
70306

*211 and 306 should be 0211 and 0306, but only if its plant 17

 

Thanks!

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi , @theu1996 

As mention by  @UAV-Test-Pilot  ,If the data is lost in excel,I would suggest you to  format  you table column as text in excel before  you enter data.

 

48.png

 

Then check whether the data lost in data previews.

 

49.png

 

 

For how to fill in the missing data, please follow the steps below:

1.exacte the first character of  column"machine"

50.png

 

2.create custom column "missingdata" as below:

custome column formula as belowL

=if [Plant] = 17 and ([First Characters of Machine] <> "0")  then 0 else ""

 

52.png

 

3.merge column "misssing data" and  column"machine"

53.png

 

pbix attached

 

Best Regards,
Community Support Team _ Eason
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

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi , @theu1996 

As mention by  @UAV-Test-Pilot  ,If the data is lost in excel,I would suggest you to  format  you table column as text in excel before  you enter data.

 

48.png

 

Then check whether the data lost in data previews.

 

49.png

 

 

For how to fill in the missing data, please follow the steps below:

1.exacte the first character of  column"machine"

50.png

 

2.create custom column "missingdata" as below:

custome column formula as belowL

=if [Plant] = 17 and ([First Characters of Machine] <> "0")  then 0 else ""

 

52.png

 

3.merge column "misssing data" and  column"machine"

53.png

 

pbix attached

 

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

UAV-Test-Pilot
Helper II
Helper II

@theu1996  In your excel source, is the leading 0 there?

 

If yes, then you can change the formatting of the column to be text in PowerQuery, but be sure to do this step above any automatic formatting PowerQuery already applied to the source, as that is what is dropping the information.

 

If no, you can create a custom column to add the 0, when plant = '17' like this:

if ([Plant] = "17" and [Machine] = "211") then "0211" else if ([Plant] = "17" and [Machine] = "306") then "0306" else [Machine]

 

If this helped, I would appreciate a Kudos!
If this resolves the issue, please mark it as a Solution! 🙂

 

Greg_Deckler
Community Champion
Community Champion

@theu1996 - Use a SWITCH(TRUE()...) statement.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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 Kudoed Authors