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
Mangnuel
Frequent Visitor

Replace any Value/Text/String by number

Hello everyone,

I need your help again, thanks in advance.

While importing an excel-file via power query into power bi
we need to secure that within two differnt columns the inputs are always the same.
The bleonging cells could contain a Text, maybe a number or just one letter.
Doesn't really matter what's within the cells, as long as it is not empty I would like to replace the input of the cell with a number.
So how can I check if a cell is not empty in generell and replace or overight the input with a defined static variable.

Many Thanks in advance

Raphael

1 ACCEPTED SOLUTION
Akash_Varuna
Super User
Super User

hi try these formulas

                                 1 In Power Query, use the formula
                                    if Text.Trim([Column1]) <> "" then 1 else [Column1] in a Custom Column to replace non-                                    empty cells in Column1 with a static number like 1.

                                  2 To overwrite a column directly, use

                                     Table.TransformColumns(Source, {{"Column1", each if Text.Trim(_) <> "" then 1 else _,                                           type number}}).
if this post helps please accept as this solution and give a kudos

 

 

View solution in original post

5 REPLIES 5
v-karpurapud
Community Support
Community Support

Hi @Mangnuel 

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.

Thank you.

v-karpurapud
Community Support
Community Support

Hi @Mangnuel 

Hope you are doing well!

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

 

 

v-karpurapud
Community Support
Community Support

Hi @Mangnuel 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

 

v-karpurapud
Community Support
Community Support

Hi @Mangnuel 

Thanks for reaching out to Microsoft Fabric Community Forum.

We found the answers provided by @Akash_Varuna works perfectly. Please consider trying them out to check if they work for you. 

I have recreated your scenario using sample data it works fine .

 vkarpurapud_1-1737616982802.png

If they work, please consider marking them 'Accept as Solutionand give a KUDOS.
Thank You.

 

 

 

 

         

 

 

 

Akash_Varuna
Super User
Super User

hi try these formulas

                                 1 In Power Query, use the formula
                                    if Text.Trim([Column1]) <> "" then 1 else [Column1] in a Custom Column to replace non-                                    empty cells in Column1 with a static number like 1.

                                  2 To overwrite a column directly, use

                                     Table.TransformColumns(Source, {{"Column1", each if Text.Trim(_) <> "" then 1 else _,                                           type number}}).
if this post helps please accept as this solution and give a kudos

 

 

Helpful resources

Announcements
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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