Forum Discussion

Mlemmers's avatar
Mlemmers
Icon for Helper I rankHelper I
2 years ago
Solved

Proper Case function with exception of prepositions in M

Hello smart people,    I'd like to have a function that turns my column headers into proper case with the exception of prepositions. So far I tried this but it still capitalises prepositions. At t...
  • slorin's avatar
    2 years ago

    Hi,

     

    Step1 = Table.TransformColumnNames(
    Source,
    each Text.Combine(
    List.ReplaceMatchingItems(
    List.Transform(Text.Split(_,"_"), Text.Proper),
    {{"In","in"}, {"To", "to"}, {"For", "for"}}),
    " ")),
    Step2 = Table.TransformColumnNames(
    Step1,
    each if Text.EndsWith(_,"id")
    then Text.BeforeDelimiter(_,"id",RelativePosition.FromEnd)&" ID"
    else _)

    Stéphane