Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

My Table Pivot isn't working

I have a table with an index column [Index] as a unique identifier, an [Attribute] column which holds whether the [Result] is the category name or category result (the only two values in this column are 'Cat' and 'Result'), a [Value] column which holds either the category name or category result.

In order to split [Attribute] into two columns called [Category] and [Result] I have added a second index [Index1] starting from 0 and then performed the following query: 

= Table.Pivot(Index, List.Distinct(Index1[Attribute]), "Attribute", "Value", List.Min)

But it's telling me that the name 'Index1' isnt recognised. Am I doing something wrong? 

  • Anonymous's avatar
    Anonymous
    4 years ago

    I couldn't seem to apply the pivot I wanted from the interface. In the end I renamed my 'Key' index to [KEY] and reverted my pivot query to look at just [Index] and it worked. I have no idea why, but it did. 

4 Replies

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

    Did you write the line yourself or use the interface to produce it?

    • Anonymous's avatar
      Anonymous
      Not applicable

      HotChilli I wrote it myself, someone gave it to me and it worked before I had another Index column as a unique identifier. Now, it seems upset that I changed it to Index1

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

    Suggest using the interface ( from Transform menu) to do the pivot.

    The code is passing the wrong parameters - Index1[Attribute] is not a list, Index is probably not a table.

    At least try to do the Pivot from the interface and compare / contrast with the code written.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I couldn't seem to apply the pivot I wanted from the interface. In the end I renamed my 'Key' index to [KEY] and reverted my pivot query to look at just [Index] and it worked. I have no idea why, but it did.