+ Reply to Thread
Results 1 to 6 of 6

Table with Power Query

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-31-2012
    Location
    Sao Paulo
    MS-Off Ver
    Excel 2021
    Posts
    174

    Table with Power Query

    Hello good afternoon, how could I adapt this table with Power Query?


    Thank you
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,754

    Re: Table with Power Query

    See the attached file in which each date column and data are considered separate tables. Once in PQ, each is grouped and totaled. Merged on dates. Then accumulated horizontally. Not necessarily pretty, but works. FYI. The sums do not match your sums. I am not sure where yours came from.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,418

    Re: Table with Power Query

    Power Query(.planetaexcel.ru)
    sotnikov
    let
       from = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
       lst = List.Combine(Table.ToList(from,(x)=>List.Split(x,3))),
       tbl = Table.FromList(List.Select(lst,(x)=>x{0}<>null),(x)=>x),
       to = Table.Group(tbl,"Column1",{"Column2",each List.Sum([Column2])}),
        #"Changed Type" = Table.TransformColumnTypes(to,{{"Column1", type date}})
    in
       #"Changed Type"
    AlienSx
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        cols = Table.ToColumns(Source),
        dates = List.Combine(List.Alternate(cols, 2, 1, 1)),
        amounts = List.Combine(List.Alternate(List.Skip(cols), 2, 1, 1)),
        tbl = #table({"date", "amount"}, List.Zip({dates, amounts})),
        gr = Table.Group(tbl, "date", {"amount", (x) => List.Sum(x[amount])}),
        filter = Table.SelectRows(gr, each ([date] <> null)),
        #"Changed Type" = Table.TransformColumnTypes(filter,{{"date", type date}})
    in
        #"Changed Type"
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,053

    Re: Table with Power Query

    What does planetexcel.ru have to do with this? And sotnikov? AlienSX?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,418

    Re: Table with Power Query

    My option PQ
    let
        Source = Excel.Workbook(File.Contents("C:\Users\seven\Documents\Documents\Pasta2(11).xlsx"), null, true),
        #"Filtered Rows" = Table.SelectRows(Source, each ([Kind] = "Table") and ([Name] <> "Table2_2")),
        #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Name", Order.Ascending}}),
        #"Expanded Data" = Table.ExpandTableColumn(#"Sorted Rows", "Data", {"Column1", "Column2"}, {"Column1", "Column2"}),
        #"Removed Other Columns" = Table.SelectColumns(#"Expanded Data",{"Column1", "Column2"}),
        #"Filtered Rows1" = Table.SelectRows(#"Removed Other Columns", each ([Column1] <> "Banco A" and [Column1] <> "Banco B" and [Column1] <> "Banco C" and [Column1] <> "Banco D")),
        #"Grouped Rows" = Table.Group(#"Filtered Rows1", {"Column1"}, {{"Count", each List.Sum([Column2]), type number}}),
        #"Sorted Rows1" = Table.Sort(#"Grouped Rows",{{"Column1", Order.Ascending}})
    in
        #"Sorted Rows1"
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,053

    Re: Table with Power Query

    I asked a question about post #3 - what is your answer, ple\se? Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 01-08-2024, 09:57 PM
  2. Replies: 1
    Last Post: 08-03-2023, 09:26 AM
  3. [SOLVED] Power Pivot/Query Convert Existing Table to Query
    By trisoldee in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-23-2019, 04:27 PM
  4. POWER Query and Power Pivot Table !!
    By haitham.shop in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-06-2018, 04:09 PM
  5. Power Query and Power Pivot Table
    By haitham.shop in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-06-2018, 06:17 AM
  6. Power Query and Power Pivot Table !!
    By haitham.shop in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-06-2018, 06:15 AM
  7. POWER Query and Power Pivot Table !!
    By haitham.shop in forum Access Tables & Databases
    Replies: 0
    Last Post: 08-06-2018, 05:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1