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
lotus22
Helper III
Helper III

Converting Columns in Dataset to Categories to use in Matrix

I need to present the data in following format using Matrix or any visual

 

lotus22_0-1636486598185.png

 

However, the data is currently available in Columns. I do not have categories defined yet. I was thinking of using Unpivot Columns but that may not work as the data is combination of text,  numbers, and percentages. Looking for feedback for how I can take data below to format as above?

 

lotus22_1-1636486630632.png

 

 

Tables

 

SafetyRecordable Incidences
Lost Time Incidences
Safety Comments
QualityCustomer Concerns
Customer Concerns Details
Warranty Calls
Warranty Calls Details
Liaison Calls
Liaison Calls Details
Cost of Quality

 

Recordable IncidencesLost Time IncidencesSafety CommentsCustomer ConcernsCustomer Concerns DetailsWarranty CallsWarranty Calls DetailsLiaison CallsLiaison Calls DetailsCost of Quality 

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @lotus22 ,

You can try this query and use a matrix to show the hierarchy in Power BI:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTLQA5GOQOwExM5AbAzEpkBsBsSWIL6pqlJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Recordable Incidences" = _t, #"Lost Time Incidences" = _t, #"Safety Comments" = _t, #"Customer Concerns" = _t, #"Customer Concerns Details" = _t, #"Warranty Calls" = _t, #"Warranty Calls Details" = _t, #"Liaison Calls" = _t, #"Liaison Calls Details" = _t, #"Cost of Quality" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Recordable Incidences", Int64.Type}, {"Lost Time Incidences", type number}, {"Safety Comments", type text}, {"Customer Concerns", type text}, {"Customer Concerns Details", type text}, {"Warranty Calls", Int64.Type}, {"Warranty Calls Details", Int64.Type}, {"Liaison Calls", Int64.Type}, {"Liaison Calls Details", Int64.Type}, {"Cost of Quality", Percentage.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),
    #"Added Index" = Table.AddIndexColumn(#"Unpivoted Columns", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Category", each if [Index] <= 3 then "Safety" else "Quality",type text),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    #"Removed Columns"

vyingjl_0-1636681590685.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yingjl
Community Support
Community Support

Hi @lotus22 ,

You can try this query and use a matrix to show the hierarchy in Power BI:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTLQA5GOQOwExM5AbAzEpkBsBsSWIL6pqlJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Recordable Incidences" = _t, #"Lost Time Incidences" = _t, #"Safety Comments" = _t, #"Customer Concerns" = _t, #"Customer Concerns Details" = _t, #"Warranty Calls" = _t, #"Warranty Calls Details" = _t, #"Liaison Calls" = _t, #"Liaison Calls Details" = _t, #"Cost of Quality" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Recordable Incidences", Int64.Type}, {"Lost Time Incidences", type number}, {"Safety Comments", type text}, {"Customer Concerns", type text}, {"Customer Concerns Details", type text}, {"Warranty Calls", Int64.Type}, {"Warranty Calls Details", Int64.Type}, {"Liaison Calls", Int64.Type}, {"Liaison Calls Details", Int64.Type}, {"Cost of Quality", Percentage.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),
    #"Added Index" = Table.AddIndexColumn(#"Unpivoted Columns", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Category", each if [Index] <= 3 then "Safety" else "Quality",type text),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    #"Removed Columns"

vyingjl_0-1636681590685.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.