Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

New rows from columns

Hi folks,

I'm trying to create new rows from columns. Eg.:

From this:

 

To this:

Any help?

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    Please try:

    New Table = 
    var _t1=SELECTCOLUMNS('Table',"Name",[Column1],"Start",[Column2],"End",[Column3])
    var _t2=SELECTCOLUMNS('Table',"Name",[Column1],"Start",[Column4],"End",[Column5])
    return FILTER( DISTINCT( UNION(_t1,_t2)) ,[Start]<>BLANK() && [End]<>BLANK())

     

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

2 Replies

  • TheoC's avatar
    TheoC
    Community Champion

    Hi Anonymous 

     

    If you go into Power Query, you can select all columns you want to unpivot. Right click on the header of one and click Unpivot Columns.

     

    Hopefully gets you the results you're after.

     

    All the best.

    Theo

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please try:

    New Table = 
    var _t1=SELECTCOLUMNS('Table',"Name",[Column1],"Start",[Column2],"End",[Column3])
    var _t2=SELECTCOLUMNS('Table',"Name",[Column1],"Start",[Column4],"End",[Column5])
    return FILTER( DISTINCT( UNION(_t1,_t2)) ,[Start]<>BLANK() && [End]<>BLANK())

     

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