Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Get data from one column in 2 different columns

Hello,

 

If I have these 2 tables:

 

id      name      age
1       Jack         23
2       Peter       34
3       Loic         56

 

Id       UserId         feature          value
1           1                eyes           brown
2           1                sex             male
3           2                eyes           blue
4           2                sex              male
5           3                eyes           brown
6           3                sex             female

 

And I would like to get the following data extend, how I can get it?

 

id          name          age          eyes        sex
1           Jack            23            brown     male
2           Peter          34            blue        male
3           Loic            56            blown      female

 

  • Hi Anonymous ,

     

    You need to do the following steps:

    • Table2:
      • Select columns feature and value
      • Pivot columns without aggreagation of values
      • Fill down  on eyes column
      • Fill up on sex column
      • Remove ID column
      • Remove duplicates
    • Table1
      • Merge with table2
      • Expand sex and eyes column

    Check PBIX file attach.

     

1 Reply

  • Hi Anonymous ,

     

    You need to do the following steps:

    • Table2:
      • Select columns feature and value
      • Pivot columns without aggreagation of values
      • Fill down  on eyes column
      • Fill up on sex column
      • Remove ID column
      • Remove duplicates
    • Table1
      • Merge with table2
      • Expand sex and eyes column

    Check PBIX file attach.