Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

column to row relationship

Hi,

I have two tables(table1 and table 2), the column names of table 1(1,2,3,4,5)

is refering to values of table 2, how can we get a column(table1) to row(table2) relationship.

 

Table 1

12345
hofga
hkgse
ijfjs
ojjf

f

 

Table 2

ValuesColumnHeading
1What is your name?
2Where are you from?
3How are you doing?
4Can I help you?
5Where are you going to?

 

Thanks,

Ravi

  • Unpivot Table 1 in query editor then relate 'Table 1'[New Value Column] to 'Table 2'[Values].

  • Hi Anonymous,

     

    To relate two tales, there should have a common column in those two tables. In your scenario, you can open Query Editor, select the query Table1, select all columns then click Unpivot Columns.

     

     

     

    Then apply the changes, go to the report, create a relationship. For more information, please check attached .pbix file.

     

     

    Best Regards,
    Qiuyun Yu

5 Replies

  • v-qiuyu-msft's avatar
    v-qiuyu-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous,

     

    To relate two tales, there should have a common column in those two tables. In your scenario, you can open Query Editor, select the query Table1, select all columns then click Unpivot Columns.

     

     

     

    Then apply the changes, go to the report, create a relationship. For more information, please check attached .pbix file.

     

     

    Best Regards,
    Qiuyun Yu

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks All, UnPivot other columns worked well for me!

    • cynthiaAA's avatar
      cynthiaAA
      New Member

      Hello! Thank you for sharing this, it was very helpful and worked! But in the process I lost the data from the original Table1. Is there a way to unpivot, create the relationship, and then transform back to the original table while maintaining the new relationship? I tried pivoting, but it didn't work.

  • Unpivot Table 1 in query editor then relate 'Table 1'[New Value Column] to 'Table 2'[Values].

  • Gatot's avatar
    Gatot
    Regular Visitor

    Hi,

     

    I have two tables , table 1 is main table and table 2 is Unpivot column. I m trying to make relationship between them but unfortunately an error message shown ("Column "INTNR" in Tables 2 contains a duplicate value and not allowed).

    Tables 1

    INTNRD2D3D4D4_1D6
    70910First vehicle everMale 35 ~ 39 yearsSelf employee
    70911Additional vehicle for my householdMale Older than 50, specifySelf employee
    70912Additional vehicle for my householdFemale 40 ~ 49 yearsHousewife
    70913First vehicle everMale 40 ~ 49 yearsGovernment employee
    70914Replacement vehicle for my householdMale 40 ~ 49 yearsPrivate company employee
    70915Replacement vehicle for my householdFemale 35 ~ 39 yearsPrivate company employee

     

    Table 2 (unpivot column)

    INTNRAttributeValue
    70910NATIONALNATIONAL
    70910REGIONREGION
    70910DEALERBlank
    70911NATIONALNATIONAL
    70911REGIONREGION
    70911DEALERBlank
    70912NATIONALNATIONAL
    70912REGIONREGION
    70912DEALERBlank
    70913NATIONALNATIONAL
    70913REGIONREGION
    70913DEALERBlank
    70914NATIONALNATIONAL
    70914REGIONREGION
    70914DEALERBlank
    70915NATIONALNATIONAL
    70915REGIONREGION
    70915DEALERBlank

     

     

    Thanks,

    Gatot