Forum Discussion

MrTD's avatar
MrTD
Frequent Visitor
9 years ago
Solved

Building a path based of column data in Power Query

Hey,

I need to build a table in Power BI (preferably in Power Query) based of dates.  I want to create a series of data in a column (I can split it later) where the ID is the same. Poorly explained so an example:

 A user with ID "1" has numerous rows in a table with different dates. On each row there's another column with data about the user "1".

 I'd like to create another table where it has the ID "1" and a column(s) probably seperated with commas with all the data information about "1" in order of earliest to latest date.
Also there are numerous other ID's with all this information.

 


I thought of doing a pivot table but this is fairly new to me so I don't know the specifics. Thing is I can do this in Excel/VBA but when it comes to this there's no good documentation :( EDIT: Plus the table I'm working with has 7 million rows, so I figured Power BI would be the best tool for this.

 

I also have another question.  I also want to do the same thing but based of the date where the data in the second column is the week number of the date, also seperated by columns. This seems like a lot to ask I think, but could also someone explain what they've done as I want to learn ad deepen my knowledge too :smileymad:

 

thank you!


  • Prerequisite: column OtherData is in text format.

     

    I used option "Group By" with operation "All Rows" and adjusted the code to have the resulting tables (1 per ID) sorted by DateTime, and OtherData combined to 1 CSV string.

     

    Edit: "1 table per ID" is during the Group By operation. The end result is 1 table in total.

     

    let
        Source = Table1,
        #"Grouped Rows" = Table.Group(Source, {"ID"}, {{"data", each Text.Combine(Table.Sort(_, "DateTime")[OtherData],","), type text}})
    in
        #"Grouped Rows"

     

    Not sure if this will perform well, with 7 million rows...

3 Replies

  • MarcelBeug's avatar
    MarcelBeug
    Community Champion

    Prerequisite: column OtherData is in text format.

     

    I used option "Group By" with operation "All Rows" and adjusted the code to have the resulting tables (1 per ID) sorted by DateTime, and OtherData combined to 1 CSV string.

     

    Edit: "1 table per ID" is during the Group By operation. The end result is 1 table in total.

     

    let
        Source = Table1,
        #"Grouped Rows" = Table.Group(Source, {"ID"}, {{"data", each Text.Combine(Table.Sort(_, "DateTime")[OtherData],","), type text}})
    in
        #"Grouped Rows"

     

    Not sure if this will perform well, with 7 million rows...

    • MrTD's avatar
      MrTD
      Frequent Visitor

      Thanks this is what I needed!