Forum Discussion

labuser1235's avatar
labuser1235
Helper IV
6 years ago
Solved

Pivot creates duplicate values

Hi All,

 

I am trying to create a pivot for different types in a column. However, it creates multiple TIDs based because of the pivot. 

 

I am aware that I can use fill up or fill down so that I can remove duplicate TIDs to get the data right. However, this cannot be done when there is a null value in between and the process fails.

 

Also tried to create different tables and merge based on TIDs. However, this needs multiple duplicate or referenced tables and this fails when there are so many types in the pivot column. 

 

Is there a way where we can achieve without using the above mentioned steps even by calculated columns or any other method required to work on. 

 

DATA

TIDFIDFnameFdata
4431Type-A10
4432Type-B15
4433Type-C25
4434Type-D35
4435Type-E60
4661Type-A100
4662Type-B150
4663Type-C 
4664Type-D350
4665Type-E600
1241Type-A120
1242Type-B140
1243Type-C 
1244Type-D330
1245Type-E660
6511Type-A110
6512Type-B 
6513Type-C220
6514Type-D380
6515Type-E607
7261Type-A 
7262Type-B105
7263Type-C205
7264Type-D30
7265Type-E60

 

 

Expected output:

TIDType-AType-BType-CType-DType-E
4431015253560
466100150 350600
124120140 330660
651110 220380607
726 1052053060

 

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi labuser1235 ,

     

    Remove the FID column and pivot Fname column with Fdata as value column should work.

     

    Best Regards,

    Jay

     

    Community Support Team _ Jay Wang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

8 Replies

  • nandukrishnavs's avatar
    nandukrishnavs
    Community Champion

    labuser1235 

     

    Try this PQ

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdI7DsMgEEXRrSBqR4JhwGnz20E6y2X6tNl9TOyR3mNSWLJ1QL4aWJaoWuIU8/Y8P+/X6dI/UlwnEzG5dqkgxeTWl6Goyb0vQ6kmj+2lHf9pzRcgDQlI1BAAhgTcMzTslEVdhCBxhCL9idiBIwru4YhjEq1mF5GRKCIA8FkI7uGIM9IwiflHs7jjCAA8h1SBOIKIIxKIuxHrFw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [TID = _t, FID = _t, Fname = _t, Fdata = _t]),
        #"Removed Columns" = Table.RemoveColumns(Source,{"FID"}),
        #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Fname]), "Fname", "Fdata")
    in
        #"Pivoted Column"



    Did I answer your question? Mark my post as a solution!
    Appreciate with a kudos
    🙂

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi labuser1235 ,

     

    Remove the FID column and pivot Fname column with Fdata as value column should work.

     

    Best Regards,

    Jay

     

    Community Support Team _ Jay Wang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • labuser1235 , Looking at the data this seem like case of matrix with TID as row Fname as column and  Fdata value.

     

    I am missing something?

  • labuser1235  Looking at the data this seem like case of matrix with TID as row Fname as column and  Fdata value.

     

    I am missing something?

    • labuser1235's avatar
      labuser1235
      Helper IV

      Hi Amit ,

       

      I was expecting to have the output saved in another table with the help of transformations if any with power query so that I can club that with another values in the table visual. Hope this is clear.

  • Hi labuser1235 ,

     

    I don't think without edit query transactions if you can get a new table.

    If in case you don't want a new table, you can use MATRIX visual,

    On matrix visual, you can have TID on Row section, FName under Column section and your summarised metric under VALUE section.

     

    If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

     

    Thanks,

    Pragati

    • labuser1235's avatar
      labuser1235
      Helper IV

      Pragati11 I donot want to use matrix visual... I would like the output to get achieved in table visual as I am also clubing it with another data from another tables. 

       

      I would like to get that achieved as an output with the help of transformaitons using power query or calculated columns,so that I can use in table visual.

      • Pragati11's avatar
        Pragati11
        Super User

        Hi labuser1235 ,

         

        In that case try replacing null values in TID column with a value like "Unknown ID" or "ID Missing".

        Then try the usual pivot steps in query editor.

         

        If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

         

        Thanks,

        Pragati