Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello All,
I am trying to do a text.insert for a report only when a condition is satisfied. I am not at liberty to divulve any part of the actual data, so unfortunately I can't provide any sample data.
But basically, I would like to loop through the column "LC", check the length of the string for each row, if it is less than 3 then I will want to insert say 0 in postion 0 of the string, else I will keep the original string. Not sure if its a syntax problem or something else. Can anyone point me in the right dirrection?
= Table.TransformColumns(#"Changed Type", {{"LC", each if Text.Length([LC]) ❤️ then Text.Insert([LC],0, "0") else [LC], type text}})
Solved! Go to Solution.
Text.Length([LC]) should be Text.Length([LC]) < 3
and whereever you have used LC, replace it with _
_ Means current record which is [LC}
Hence, your formula would become
= Table.TransformColumns(#"Changed Type", {{"LC", each if Text.Length(_)<3 then Text.Insert(_,0, "0") else _, type text}})
Also Text.Insert(_,0, "0") can be replaced with "0"&_ and also 1 { is sufficient, 2 { are not needed.
= Table.TransformColumns(#"Changed Type", {"LC", each if Text.Length(_)<3 then "0"&_ else _, type text})
Text.Length([LC]) should be Text.Length([LC]) < 3
and whereever you have used LC, replace it with _
_ Means current record which is [LC}
Hence, your formula would become
= Table.TransformColumns(#"Changed Type", {{"LC", each if Text.Length(_)<3 then Text.Insert(_,0, "0") else _, type text}})
Also Text.Insert(_,0, "0") can be replaced with "0"&_ and also 1 { is sufficient, 2 { are not needed.
= Table.TransformColumns(#"Changed Type", {"LC", each if Text.Length(_)<3 then "0"&_ else _, type text})
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
12 | |
8 | |
8 | |
7 |
User | Count |
---|---|
15 | |
13 | |
7 | |
6 | |
5 |