Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Merging Queries and then Pivoting?

I have two tables (Table 1 and Table 2) from the same Excel file into Power BI. This Excel file is updated weekly. What I've been trying to do--I am not sure if I'm going about it the right way-- is to unpivot and merge each table (Table 1 and Table 2) as a new query (New Merged Table)and do the necessary work from there.

 

  1. Will my original tables, now unpivoted (Table 1 Unpivoted and Table 2 Unpivoted) continue to update if I refresh them with updated data, after they've been unpipvoted?
  2. If I don't have relationships between these original tables and the New Merged Table, will the data continue to update in this new merged table with the data coming from the original two tables?
  3. Lastly, to keep all of the relevant rows for the Table1Value and Table2Value columns, would I want to use a Full Outer Join on these to preserve that? It's worth mentioning that I have a date lookup table that I can create a relationship with to help with any Week duplicates.


Table 1

WeekYearArea AArea BArea C
1/1/20102010578
1/8/20102010479
5/11/201820183

4

3

 

 

Table 1 Unpivoted

WeekYearAreaValue
1/1/20102010A5
1/1/20102010B7
1/1/20102010C8
1/8/20102010A4
1/8/20102010B7
1/8/20102010C9

 

 

Table 2

WeekYearArea AArea BArea C
1/8/20102010.2.3.5
5/11/20182018.1.2.2

 

Table 2 Unpivoted

WeekYearAreaValue
1/1/20102010A.2
1/1/20102010B.3
1/1/20102010C.5
5/11/20182018A.1
5/11/20182018B .2
5/11/20182018C.2

 

New Merged Table

WeekYearAreaTable1ValueTable2 Value
1/1/20102010A5null
1/1/20102010B7null
1/1/20102010C8null
1/8/20102010A4

.2

1/8/20102010B7.3
1/8/20102010C9.5
5/11/20182018A3.1
5/11/20182018B4.2
5/11/20182018C3.2

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi  Anonymous ,

    According to the test, when you refresh in Excel, both your original table A and original table B will be refreshed, and the new table AB formed by combining the original table A and the original table B will also be refreshed.

    And P_A and P_B formed by Pivoting will also refresh the data, and the merge of P_A and P_B into a new table P_AB will also be refreshed.

     

    If you want to keep all related rows of the Table1Value and Table2Value columns, you can use the JoinKind method of Full Outer in the merge to keep it.

     

    Both the merging and pivoting steps are implemented after the data is loaded.

     

    Best Regards,

    Liu Yang

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

3 Replies

  • Anonymous , Unpivoted/merge  is the step added on the table you added to power bi, then they should continue work with refresh or new data

    • Anonymous's avatar
      Anonymous
      Not applicable

      If I'm understanding your response correctly, you're saying that if I unpivot my original tables and then merge as a new query, even though they won't have a relationship with that new table except through that merge, then my data will continue to load as it's updated and refreshed?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    According to the test, when you refresh in Excel, both your original table A and original table B will be refreshed, and the new table AB formed by combining the original table A and the original table B will also be refreshed.

    And P_A and P_B formed by Pivoting will also refresh the data, and the merge of P_A and P_B into a new table P_AB will also be refreshed.

     

    If you want to keep all related rows of the Table1Value and Table2Value columns, you can use the JoinKind method of Full Outer in the merge to keep it.

     

    Both the merging and pivoting steps are implemented after the data is loaded.

     

    Best Regards,

    Liu Yang

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