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
philip1996
Regular Visitor

Joining Columns into 1

Hi, I'm trying to do the following in power bi, but cross join is not working for me, any help would be appriciated

 

Before

classic.PNG

 

 

After

changed.PNG

1 ACCEPTED SOLUTION
Michal_cwiok
Resolver II
Resolver II

I would tackle to problem by splitting the table into two and appending the query.

 

Paste this code into Advanced Editor in your PowerBI to see the solution.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLTMzDUMzIwNFPSUQoKd3EGUpFKsTpAGSM9AyOYjA9Exg8sY2CqZ2CCJgPRAxQGSmKTAdmDRSYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Severity = _t, isReportable = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Severity", type text}, {"isReportable", type text}}),
    First_part = Table.RemoveColumns(#"Changed Type",{"isReportable"}),
    Second_part = Table.RemoveColumns(#"Changed Type",{"Severity"}),
    Second_part_rename = Table.RenameColumns(Second_part,{{"isReportable", "Severity"}}),
    #"Appended Query" = Table.Combine({Second_part_rename ,  First_part}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Date", Order.Ascending}}),
    #"Replaced Value" = Table.ReplaceValue(#"Sorted Rows","Y","Reportable",Replacer.ReplaceText,{"Severity"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","N","Not Reportable",Replacer.ReplaceText,{"Severity"})
in
    #"Replaced Value1"

 

My final result:

post1.png

View solution in original post

1 REPLY 1
Michal_cwiok
Resolver II
Resolver II

I would tackle to problem by splitting the table into two and appending the query.

 

Paste this code into Advanced Editor in your PowerBI to see the solution.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLTMzDUMzIwNFPSUQoKd3EGUpFKsTpAGSM9AyOYjA9Exg8sY2CqZ2CCJgPRAxQGSmKTAdmDRSYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Severity = _t, isReportable = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Severity", type text}, {"isReportable", type text}}),
    First_part = Table.RemoveColumns(#"Changed Type",{"isReportable"}),
    Second_part = Table.RemoveColumns(#"Changed Type",{"Severity"}),
    Second_part_rename = Table.RenameColumns(Second_part,{{"isReportable", "Severity"}}),
    #"Appended Query" = Table.Combine({Second_part_rename ,  First_part}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Date", Order.Ascending}}),
    #"Replaced Value" = Table.ReplaceValue(#"Sorted Rows","Y","Reportable",Replacer.ReplaceText,{"Severity"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","N","Not Reportable",Replacer.ReplaceText,{"Severity"})
in
    #"Replaced Value1"

 

My final result:

post1.png

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.