Forum Discussion

cathoms's avatar
cathoms
Responsive Resident
5 years ago
Solved

Remove subset of rows

Hello. I am trying to automate a task that currently invovles a lot of copy and paste in Excel with the end goal of a dataset for Power BI. Currently, we run reports from a website that produces an e...
  • Jimmy801's avatar
    Jimmy801
    5 years ago

    Hello cathoms 

     

    I combined now both data into one table. The main table is basically created by checking the content of two columns.. basically creating the table from backwards until criteria a matching. Then extract with Table.SelectRows the value of your site and add it as new column. Here the complete code

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtKBoVidaCVn32BUAVRecGpRWWZyKpCblllUXIJTHZouzxBXIDsRCIjU4ZaZU5JahE8FLncVpybn56UAGYWlqcUlmfl5ILHSorLUSrBCQ1R9RqhcY1SuCSrXFJVrRrzznB09AvCGKy7flGRkFiF7BiRWlphTmgpW5wjkgTwEcqehIVwI5CmQW42M4EIgj4Hca2ysFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Colonna3 = _t, Colonna4 = _t]),
        Last = Table.RemoveFirstN(Source, each ([Column1]<>"Service" or [Column2]<>"third")),
        #"Promoted Headers" = Table.PromoteHeaders(Last, [PromoteAllScalars=true]),
        GetSite = Table.SelectRows(Source, each [Column1]= "SITE"){0}[Column2],
        AddSiteToTable = Table.AddColumn
        (
            #"Promoted Headers",
            "Site", 
            each GetSite
        )
        
    in
        AddSiteToTable

    and this is the output

     

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy