Forum Discussion

DGuzmanG's avatar
DGuzmanG
Copper Contributor
Mar 06, 2020
Solved

How to number each occurrence of a substring in a cell in Power Query?

Hello, I'm fairly new to Power Query and have hit a hiccup that's been bothering me all day. I've read multiple threads here and on the Power BI community and none has really cleared my question, an...
  • SergeiBaklan's avatar
    SergeiBaklan
    Mar 06, 2020

    ChrisMendoza 

    I'd simplify a bit

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKijKTylNLtHNS8xN1csqSFfSUTJWitWJVsovyUgt0oVKQ2VMlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Image Base Name" = _t, ImageQty = _t]),
        AddImageIDs = Table.AddColumn(
            Source,
            "ImageIDs",
            each
                Text.Combine(
                    List.Transform(
                        {1..Number.FromText([ImageQty])},
                        (x)=>
                            Text.BeforeDelimiter([Image Base Name],".") &
                            "-" &
                            Text.From(x) &
                            "." &
                            Text.AfterDelimiter([Image Base Name],".")
                    ),
                    " "
                )
        )
    in
        AddImageIDs

     

Resources