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
Anonymous
Not applicable

column formatting issues

I am having an issue where rather than showing the ID multiple times i want to show ID once but the Type region and price to all appear on the same line rather than seperate please see example dataCapture.JPG

1 ACCEPTED SOLUTION

hi @Anonymous 

For this error, it means you have more than one value in same Megerd ID for Type or Region or Price.

It like this:

2.JPG

 

So please adjust the Pivot function as below:

3.JPG

 

here is M code, you could try it.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrOzc8vyQAy/PKLwLSCUqwOREoBpygI++SXg8WM8IgF55ci6QaJeiQWpcA1xMYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Merged = _t, Type = _t, Region = _t, Price = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Merged", Int64.Type}, {"Type", type text}, {"Region", type text}, {"Price", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type"," ",null,Replacer.ReplaceValue,{"Type", "Region", "Price"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Merged"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value", List.Max)
in
    #"Pivoted Column"

 

Regards,

Lin

Community Support Team _ Lin
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

8 REPLIES 8
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

If you are referring matrix visual layout?

Then you can switch off the stepped layout.

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Anonymous
Not applicable

@Mariusz  sorry bad explanation i need to do this in Power Bi in M Query. As these columns need to be filters, i have tried pivotting the data then unpivotting but i get an error as says there can't be multiples

Hi @Anonymous 

 

Can you paste the sample from Excel into the body of this post?

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Anonymous
Not applicable

@Mariusz 

MergedTypeRegionPrice
1Smooth  
1 North 
1  Low
2  Low
2 South 
2Hard  

Hi @Anonymous 

 

Try this 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrOzc8vyQAyFMA4VgciDOL55RdBZZBFQdgnvxwsZoRHLDi/FEk3SNQjsSgFYVEsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Merged = _t, Type = _t, Region = _t, Price = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Merged", Int64.Type}, {"Type", type text}, {"Region", type text}, {"Price", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type"," ",null,Replacer.ReplaceValue,{"Type", "Region", "Price"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Merged"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

or see the attached 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Anonymous
Not applicable

@Mariusz thank you for this but i am getting the following erro;

Expression.Error: There were too many elements in the enumeration to complete the operation.
Details:
[List]

 

 

This is down to duplicates but i need these to be in there, thats the main part i am having issue with

hi @Anonymous 

For this error, it means you have more than one value in same Megerd ID for Type or Region or Price.

It like this:

2.JPG

 

So please adjust the Pivot function as below:

3.JPG

 

here is M code, you could try it.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrOzc8vyQAy/PKLwLSCUqwOREoBpygI++SXg8WM8IgF55ci6QaJeiQWpcA1xMYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Merged = _t, Type = _t, Region = _t, Price = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Merged", Int64.Type}, {"Type", type text}, {"Region", type text}, {"Price", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type"," ",null,Replacer.ReplaceValue,{"Type", "Region", "Price"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Merged"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value", List.Max)
in
    #"Pivoted Column"

 

Regards,

Lin

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

Hi @Anonymous 

 

Can you provide the data sample that includes duplicates?

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

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.