Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hello,
One column in my table is a list of strings. I would like to change the strings to lower case if their lenghts is greater than 1.
| Name | Types |
| N1 | A,ABC,B,CDF,DF |
| N2 | H,JKL,BG,DC,C |
Convert to
| Name | Types |
| N1 | A,abc,B,cdf,df |
| N2 | H,jkl,bg,dc,C |
Can somebody help?
Thank you
Solved! Go to Solution.
Here is one way to do this...
= Table.TransformColumns(previousQueryStep, {{"Types", each Text.Combine(List.Transform(Text.Split(_, ","), each if Text.Length(_) > 1 then Text.Lower(_) else _), ","), type text}})
Using your example table you end up with...
Proud to be a Super User! | |
For fun only, to incorporate the power of regex,
import re
import numpy as np
df['Types']=np.vectorize(lambda string:re.compile(r'[a-z]{2,}(?=\b)',flags=re.I).sub(lambda match:str.lower(match.group(0)),string))(df['Types'])let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8jNUUFBQ0lFy1HF0ctZx0nF2cdNxcVOK1QFKGQHFPXS8vH10nNx1XJx1nJViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Types = _t]),
#"Run Python script" = Python.Execute("import re#(lf)import numpy as np#(lf)df['Types']=np.vectorize(lambda string:re.compile(r'[a-z]{2,}(?=\b)',flags=re.I).sub(lambda match:str.lower(match.group(0)),string))(df['Types'])",[df=Source]),
df = #"Run Python script"{[Name="df"]}[Value]
in
df
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8jNUUFBQ0lFy1HF0ctZx0nF2cdNxcVOK1QFKGQHFPXS8vH10nNx1XJx1nJViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Name " = _t, Types = _t]),
chars = List.Buffer({"a".."z", "A".."Z"}),
result = Table.TransformColumns(
Source,
{
"Types",
(x) => Text.Combine(
List.Transform(
Text.Split(x, ","),
(w) => if List.Contains(chars, w) then w else Text.Lower(w)
),
","
)
}
)
in
result
Here is one way to do this...
= Table.TransformColumns(previousQueryStep, {{"Types", each Text.Combine(List.Transform(Text.Split(_, ","), each if Text.Length(_) > 1 then Text.Lower(_) else _), ","), type text}})
Using your example table you end up with...
Proud to be a Super User! | |
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.