Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello,
I have been stuck with this problem for several days. Here is the problem:
I have data columns with numbers except some are with "," and some with "."
I would like to dynamically convert the columns containing "." to ","
Here is an example :
XXX Price | YYY Price | XXX Quantity | YYY Quantity | Product |
11,55 | 12.40 | 13.50 | 12,50 | AAAAA |
18,90 | 15.90 | 74.60 | 65,15 | BBBBBB |
21,50 | 25.90 | 54.90 | 61,10 | CCCCC |
What I want is that all the columns that contain "Price" and "Quantity" are changed to type Number by replacing the "." by ","
Knowing that it must be dynamic because I have columns "ZZZ Price" and "ZZZ Quantity" that can appear.
I tried this solution:
= Table.TransformColumns(Source, List.Transform(List.Select(Table.ColumnNames(Source),each Text.Contains(_,"Price") or Text.Contains(_,"Quantity")), (col) => {col, each _ ?? null, type text}))
This code converts everything to text which allows me to change the "." to ","
But I have an error on the columns that don't contain "." because the type of these columns don't seem to be changed to text
Thanks for your help
Paul
Solved! Go to Solution.
Thank you for your answers, they helped me find the solution.
The problem comes from my formula that allows me to dynamically change the type of columns that contain the words "Price" and "Quantity".
So I used the following formula to change the type of the columns to text :
= Table.TransformColumnTypes(Source, List.Transform(List.Select(Table.ColumnNames(Source),each Text.Contains(_,"Price") or Text.Contains(_,"Quantity")), each {_, type text}))
This allowed me to use the following formula to replace the "." by "," without error :
= Table.ReplaceValue(PreviousStep,".",",",Replacer.ReplaceText,List.Select(Table.ColumnNames(PreviousStep),each Text.Contains(_,"Price") or Text.Contains(_,"Quantity")))
Thank you for your answers, they helped me find the solution.
The problem comes from my formula that allows me to dynamically change the type of columns that contain the words "Price" and "Quantity".
So I used the following formula to change the type of the columns to text :
= Table.TransformColumnTypes(Source, List.Transform(List.Select(Table.ColumnNames(Source),each Text.Contains(_,"Price") or Text.Contains(_,"Quantity")), each {_, type text}))
This allowed me to use the following formula to replace the "." by "," without error :
= Table.ReplaceValue(PreviousStep,".",",",Replacer.ReplaceText,List.Select(Table.ColumnNames(PreviousStep),each Text.Contains(_,"Price") or Text.Contains(_,"Quantity")))
Hi @LeroyPaul ,
You want to replace the "." in multiple columns with ",", right?
If so, first make sure the columns contains "." are text type.
You can remove the "Change Types1" from Applied Steps to make them text.
Or select them and change types manually to make them text.
After the text type modification is complete, select columns at the same time, and then right-click a column to select the "Replace Values...".
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thank you for your answer.
Your solution allows me to do the operation in a static way but does not take into account the name of the columns so that it is dynamic.
As I will have new columns that will be added to my model later, these columns will not be modified using this solution.
Thanks for your explanations and for the detail of your solution
Hi @LeroyPaul - you should consider using the Replace in Multiple Columns - Gorilla BI in two steps rather than Transform Columns in one step. Use the Table.ColumnNames function to find Price and Quantity in these separate applied steps.
Thank you for your answer,
I was able to develop my thoughts with the help of this website.