Forum Discussion

TonyEssi's avatar
TonyEssi
New Member
2 years ago
Solved

How to import code to Power query/Share code between queries

Cross-posting this from Office365 Excel community as advised. I have several tables that contain data collected in each of several years and a number of queries that generate a summary of three di...
  • PwerQueryKees's avatar
    PwerQueryKees
    2 years ago

     

    let
        // All content of the workbook
        Source = Excel.CurrentWorkbook(),
        // Make sure you fileter only the content you need
        #"Filtered Register Tables" = Table.SelectRows(Source, each Text.StartsWith([Name], "tblRegister")),
        // Isolate the year.
        // You can name the columns yourself here...
        #"Split Column by Character Transition" = Table.SplitColumn(#"Filtered Register Tables", "Name", Splitter.SplitTextByCharacterTransition((c) => not List.Contains({"0".."9"}, c), {"0".."9"}), {"TablePrefix", "Year"}),
        // End Result.
        // You can choose what columns to keep here
        // By refering to this query, you can build any analysis you want
        #"Expanded Content" = Table.ExpandTableColumn(#"Split Column by Character Transition", "Content", {"Activity", "Committee", "FundingBucket", "Amount"}, {"Activity", "Committee", "FundingBucket", "Amount"})
    in
        #"Expanded Content"

     

     

    In the worksheet: