Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

Double the rows in order to add the values from another column

Hello,

 

I have the following table:

 

ID    Phase1     Phase2

1      P1              P2

2      P2              P3

3      P4               P4

 

and the output I would want:

 

ID    Phase1     Phase2      Phase

1      P1              P2             P1

1      P1              P2             P2          

2      P2              P3             P2

2      P2              P3             P3

3      P4              P4             P4

 

I mention the Phase1 & Phase2 were created by DAX.

Can someone help me out on this?

 

 

4 ACCEPTED SOLUTIONS

are you using Direct query or is there another reason?
with DAX you can create calculated table (see syntax below), but AFAIK you cannot modify the table itself to that format, you would need to do that in PowerQuery

Table 2 = 
UNION(
    ADDCOLUMNS('Table',"Phase",[Phase1]),
    ADDCOLUMNS('Table',"Phase",[Phase2])
)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

Hi @NewbiePowerBye

This calculated column can be replaced by Power Query as below

7.png

6.png

 

 

Best Regards

Maggie

 

View solution in original post

basically do the following

1) add a custom column

{[Phase1],[Phase2]}

2) expand rows in that column

3) chagne type to text

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

that would mean that the [Phase2] field's are records not text, is that the case?
this is the coe I tested with, and it expands as text

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjy0QElHKQBKGSnF6kQrGUE5EMoYLGYM4ZhAKaXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"ID " = _t, Phase1 = _t, Phase2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID ", Int64.Type}, {"Phase1", type text}, {"Phase2", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Phase", each {[Phase1],[Phase2]}),
    #"Expanded Phase" = Table.ExpandListColumn(#"Added Custom", "Phase")
in
    #"Expanded Phase"


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

11 REPLIES 11

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors