Forum Discussion

jlauyfc's avatar
jlauyfc
Frequent Visitor
2 years ago
Solved

Table grouping by passing columns name from anther table

Hi guys

 

I'm trying to group my product export csv file by a few keys and an aggregatedColumns "Variant SKU". I got errors on the aggregatedColumns column that added. I spent a few hours searching for a solution on the web, and most suggest using Record.Field to get the column data from passing a column name. Please help.

 

excel file: Product List sample.xlsm 

source csv: products_export_1.csv 

expected result: expecting result.csv 

 

Problematic code: (in table "Product List Grouped SKUs")

 

= Table.Group(#"Added Custom", Table.Column(#"Product List Header Group Key", "Key"), {{"Variant SKUs", each Text.Combine(Record.Field(Record.FromTable(#"Product List Header Group Aggregate"), "Aggregate Column"), ", ")}})

 

 

Table "Product List Header Group Aggregate":

Table "Product List Header Group Key"

 

Error

 

Error Detail 1: (this error cannot be reproduced in the sample)

Expression.Error: The key didn't match any rows in the table.
Details:
Key=
Title= xxxxx

Body (HTML)=xxxxx

....

..

Error Detail2:

Expression.Error: The field 'Name' of the record wasn't found.
Details:
Column #=Column18
Aggregate Column=Variant SKU

 

Please helpπŸ˜”

  • I can't help you with Error #1 since, as you wrote, the sample does not reproduce it.

     

    For Error #2,  try this for your #"Grouped Rows" step

        #"Grouped Rows" = Table.Group(#"Added Custom", Table.Column(#"Product List Header Group Key", "Key"), {
            {"Variant SKUs", 
        each Text.Combine(Table.Column(_, #"Product List Header Group Aggregate"[Aggregate Column]{0}),", ")}})

     

    Results

     

     

     

9 Replies

  • foodd's avatar
    foodd
    Icon for Community Champion rankCommunity Champion

    Hello jlauyfc , and thank you for sharing your question with the Community.  This reply is informational. Please follow the decorum of the Community Forum when asking a question.

    Please share your work-in-progress Power BI Desktop file (with sensitive information removed) and any source files in Excel format that fully address your issue or question in a usable format (not as a screenshot). You can upload these files to a cloud storage service such as OneDrive, Google Drive, Dropbox, or to a Github repository, and then provide the file's URL.

    https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216

    Please show the expected outcome based on the sample data you provided.

    https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523/highlight/true#M607150

    This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.

     

    If your requirement is solved, please make THIS ANSWER a SOLUTION βœ”οΈ and help other users find the solution quickly. Please hit the LIKE πŸ‘ button if this comment helps you.  Proud to be a Super User!

    • jlauyfc's avatar
      jlauyfc
      Frequent Visitor

      I am using power query in excel but not "Power BI Desktop", so what file should I share?

      • foodd's avatar
        foodd
        Icon for Community Champion rankCommunity Champion

        That is easy!  Share any related source files and your work-in-progress Excel (.xlsx) file in the same manner as you would if it were a Power BI Desktop File. By doing this, it will provide community members assisting you with a clearer understanding of your issue within the correct context. Thank you!

         

        If your requirement is solved, please make THIS ANSWER a SOLUTION βœ”οΈ and help other users find the solution quickly. Please hit the LIKE πŸ‘ button if this comment helps you.  Proud to be a Super User!

  • dufoq3's avatar
    dufoq3
    Icon for Community Champion rankCommunity Champion

    Hi jlauyfc, i do not understand the purpose but I've solved your error:
    BTW: you should read about functions before you use them, the issue was with Record.FromTable - for this function you have to specify Name and Value.

     

    = Table.Group(#"Added Custom", Table.Column(#"Product List Header Group Key", "Key"), {{"Variant SKUs", each Text.Combine(#"Product List Header Group Aggregate"[Aggregate Column], ",")}})