Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Reverse text string lookup between delimiters

Hi Folks, I'm somewhat of a newbie that requires your help/direction. I have searched the forums but cannot find a similar issue and resolution. I have been grappling with this but just cannot resolv...
  • AlB's avatar
    5 years ago

    Anonymous 

    This query reads the csv in and adds the column "New column" at the end of the table with the required content. It just follows the steps I described earlier:

    let
        Source = Csv.Document(File.Contents("d:\YOUR_PATH_HERE\Sample org hierarchy file.csv"),[Delimiter=",", Columns=39, Encoding=1252, QuoteStyle=QuoteStyle.None]),
        #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
        #"Added Custom" = Table.AddColumn(#"Promoted Headers", "New column", each List.LastN(Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)([Department Hierarchy]),2){0})
    in
        #"Added Custom"

     You'll have to update the path for the file with the actual path tou your data (in the first step--> File.Contents("d:\YOUR_PATH_HERE\Sample org hierarchy file.csv")

     

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers