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.
I have two fields that I wish to merge into one. However I would like the second field to appear at a end to the first field. The issue is the first field is variable in length. So here is my data.
Item | Records |
1. Item | 221/259 |
2. Item Brown | 218/259 |
3. Item Red | 7/8 |
4. Item No colour | 2/4 |
5. Item White | 8/24 |
I would like it to appear like this.
How do I make the lengh of the item field a standard size (longer) so that the merge appends to the end of the Item field? So the opposite of trimming the field I want to add spaces at the end of the Item Field.
Solved! Go to Solution.
Hi @STIBBS_807 ,
Here is my solution, which only displays properly in i.e. notepad:
And this is how it looks like in Power Query:
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUjDUU/AsSc1V0lEyMjLUNzK1VIrVAQobQYQVnIryy/NAkoYWCEljqGRQagpQylzfAiJsAhX2y1dIzs/JLy0C6dM3gUiaQiXDMzJLUoESQOOAMrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Item = _t, Records = _t]), #"Added Custom1" = Table.AddColumn(Source, "ItemColumnLength", each Text.Length([Item])), #"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"ItemColumnLength", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [Item] & " " & Text.Repeat(" ", (List.Max(#"Changed Type"[ItemColumnLength] ) -[ItemColumnLength] )) & [Records]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"ItemColumnLength"}) in #"Removed Columns"
Does this solve your issue? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
I replaced the spaces with a period and a space to make it look like a title page.
try use the function
Text.PadEnd(text as nullable text, count as number, optional character as nullable text) as nullable text
Hi @STIBBS_807 ,
Here is my solution, which only displays properly in i.e. notepad:
And this is how it looks like in Power Query:
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUjDUU/AsSc1V0lEyMjLUNzK1VIrVAQobQYQVnIryy/NAkoYWCEljqGRQagpQylzfAiJsAhX2y1dIzs/JLy0C6dM3gUiaQiXDMzJLUoESQOOAMrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Item = _t, Records = _t]), #"Added Custom1" = Table.AddColumn(Source, "ItemColumnLength", each Text.Length([Item])), #"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"ItemColumnLength", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [Item] & " " & Text.Repeat(" ", (List.Max(#"Changed Type"[ItemColumnLength] ) -[ItemColumnLength] )) & [Records]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"ItemColumnLength"}) in #"Removed Columns"
Does this solve your issue? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
Also happily accepting Kudos 🙂 |
Feel free to connect with me on LinkedIn! |
#proudtobeasuperuser |
I like @tackytechtom solution. Just be aware it works well with a mono-spaced font like Courier, but may not work in a font like Arial that has kerning.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingMarch 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.