# Tags
**Software** : [[02 - Tags/Software/Power Query]]
**Functions** used : [[Table.TransformColumnTypes]] [[Table.AddColumn]] [[Text.PositionOfAny]] [[Text.Length]] [[Text.Upper]] [[Text.Insert]] [[Text.Repeat]] [[Excel.CurrentWorkbook]]
**Date** : 15-March-2025
# Description
- In this case I show you how to find a pattern in specific text fields and add additional padding in the middle of a text field based on a pattern
# Video Link
<iframe width="560" height="315" src="https://www.youtube.com/embed/4hT9oLuyv5I?si=3de6QgiEwK27huNN" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
[GITHUB Link](https://github.com/jbotes/powerbiTutorials/blob/main/PQ_PadMiddle_Video.xlsx)
# M-Query
``` mquery
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CODE", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each
[
PositionofNr = Text.PositionOfAny([CODE], {"0".."9"}),
Length = Text.Length([CODE]),
LengthShortfall = 10 - Length,
Textinsert = Text.Upper(Text.Insert([CODE], PositionofNr, Text.Repeat("0", LengthShortfall))),
Repeatfunction = Text.Repeat("#", LengthShortfall)
][Textinsert])
in
#"Added Custom"
```
## Optional Tags
**Tags** :
**Technique** : [[Records to Decompose Problem]]