Forum Discussion

NayTaguada's avatar
NayTaguada
New Member
8 years ago
Solved

Power Query - Pivot Table with Don't aggregate

Hi All, 

 

I need help with a problem that I have after importing a .txt, I leave some screenshots below:

 

 

Actual values
  
Column 1Values
job_namejob_name_falsevalue
job_typejob_type_falsevalue
serverserver_falsevalue
descriptiondescription_falsevalue
applicationapplication_falsevalue
job_namejob_name_falsevalue2
folderfolder_falsevalue
job_typejob_type_falsevalue2
serverserver_falsevalue
descriptiondescription_falsevalue2
applicationapplication_falsevalue2
job_namejob_name_falsevalue3

 

 

Expected Value   
      
job_namejob_typeserverdescriptionapplicationfolder
job_name_falsevaluejob_type_falsevalueserver_falsevaluedescription_falsevalueapplication_falsevaluenone
job_name_falsevalue2job_type_falsevalue2server_falsevaluedescription_falsevalue2application_falsevalue2folder_falsevalue
job_name_falsevalue3job_type_falsevalueserver_falsevalue2description_falsevalueapplication_falsevalue3folder_falsevalue

 

Values were invented as it is confidential data.

 

When I tried to perform a pivot, the following message appears:

Expression.Error: There were too many elements in the enumeration to complete the operation.
Details:
     List

 

Does anyone have an idea of how to solve it?

 

Thanks!!

 

Nay

 

  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi NayTaguada,

     

    You can refer to below formula to group and transform records

     

    Full query.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rY9BCoAgEEXv4tqVHUckpprAsBQtodtnWhFSYNDuDfMW/3FOBt3UE4xI6IV1D8qhB7UgETQp82pOZcdccWg92iAkyN8dutZKM0s9Bed25SIYo2QLh3i7nja9z2bR6bXq4qgE37LYX12sOIwVlFVEiA0=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, Values = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column 1", type text}, {"Values", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Column 1"}, {{"Contents", each Text.Combine(_[Values],","), type text}}),
        #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Contents", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Contents.1", "Contents.2", "Contents.3"}),
        #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Contents.1", type text}, {"Contents.2", type text}, {"Contents.3", type text}}),
        #"Transposed Table" = Table.Transpose(#"Changed Type1"),
        #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
        #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers",{{"job_name", type text}, {"job_type", type text}, {"server", type text}, {"description", type text}, {"application", type text}, {"folder", type text}})
    in
        #"Changed Type2"

    Regards,

    Xiaoxin Sheng

2 Replies

  • Hi All, 

     

    I need help with a problem that I have after importing a .txt, I leave some screenshots below:

     

     

    Actual values
      
    Column 1Values
    job_namejob_name_falsevalue
    job_typejob_type_falsevalue
    serverserver_falsevalue
    descriptiondescription_falsevalue
    applicationapplication_falsevalue
    job_namejob_name_falsevalue2
    folderfolder_falsevalue
    job_typejob_type_falsevalue2
    serverserver_falsevalue
    descriptiondescription_falsevalue2
    applicationapplication_falsevalue2
    job_namejob_name_falsevalue3

     

     

    Expected Value   
          
    job_namejob_typeserverdescriptionapplicationfolder
    job_name_falsevaluejob_type_falsevalueserver_falsevaluedescription_falsevalueapplication_falsevaluenone
    job_name_falsevalue2job_type_falsevalue2server_falsevaluedescription_falsevalue2application_falsevalue2folder_falsevalue
    job_name_falsevalue3job_type_falsevalueserver_falsevalue2description_falsevalueapplication_falsevalue3folder_falsevalue

     

    Values were invented as it is confidential data.

     

    When I tried to perform a pivot, the following message appears:

    Expression.Error: There were too many elements in the enumeration to complete the operation.
    Details:
         List

     

    Does anyone have an idea of how to solve it?

     

    Thanks!!

     

    Nay

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi NayTaguada,

       

      You can refer to below formula to group and transform records

       

      Full query.

      let
          Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rY9BCoAgEEXv4tqVHUckpprAsBQtodtnWhFSYNDuDfMW/3FOBt3UE4xI6IV1D8qhB7UgETQp82pOZcdccWg92iAkyN8dutZKM0s9Bed25SIYo2QLh3i7nja9z2bR6bXq4qgE37LYX12sOIwVlFVEiA0=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, Values = _t]),
          #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column 1", type text}, {"Values", type text}}),
          #"Grouped Rows" = Table.Group(#"Changed Type", {"Column 1"}, {{"Contents", each Text.Combine(_[Values],","), type text}}),
          #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Contents", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Contents.1", "Contents.2", "Contents.3"}),
          #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Contents.1", type text}, {"Contents.2", type text}, {"Contents.3", type text}}),
          #"Transposed Table" = Table.Transpose(#"Changed Type1"),
          #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
          #"Changed Type2" = Table.TransformColumnTypes(#"Promoted Headers",{{"job_name", type text}, {"job_type", type text}, {"server", type text}, {"description", type text}, {"application", type text}, {"folder", type text}})
      in
          #"Changed Type2"

      Regards,

      Xiaoxin Sheng