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
Bundi009
Frequent Visitor

Put financial years and labels in rows (not columns)

Hi experts,

 

I am desperately trying to get my financial data next to each other. In short, I want to have 4/5 columns with customer information and then show sales, quantity and costs for each line for 2021 AND 2022. Right now they are under each other,

but I want them next to each other (so 2021.Aantal, 2022.Aantal etc). Can anyone tell me the the magic trick? Thank you very much in advance!

2d7fe724-923c-47fb-94b5-52f1f1d594a6.png

 

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Bundi009 ,

 

If you want this:

Eyelyn9_2-1657170047227.png

Please follow the steps——Unpivot-->Add column-->Remove other columns. Below is the whole M syntax:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckzMK0nMUdJRMjYAEkYWSrE60UoBRZlZxUCuiaWeBUjKDCwakl+SmJijkJdaUpIPFDU3MQcpMbUES8LNMQSZY2iEYo6RqZ6JKcggUz2sRhmZmOiB5Q0M9IwMlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Attribute = _t, #"2021" = _t, #"2022" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Attribute", type text}, {"2021", type number}, {"2022", type number}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Attribute"}, "Attribute.1", "Value"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Custom", each [Attribute.1] &"."& [Attribute]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Attribute", "Attribute.1"})
in
    #"Removed Columns"

 

Or if you want this:

Eyelyn9_3-1657170122757.png

Then use "Pivot" after the steps above.

 


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.

View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @Bundi009 ,

 

If you want this:

Eyelyn9_2-1657170047227.png

Please follow the steps——Unpivot-->Add column-->Remove other columns. Below is the whole M syntax:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckzMK0nMUdJRMjYAEkYWSrE60UoBRZlZxUCuiaWeBUjKDCwakl+SmJijkJdaUpIPFDU3MQcpMbUES8LNMQSZY2iEYo6RqZ6JKcggUz2sRhmZmOiB5Q0M9IwMlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Attribute = _t, #"2021" = _t, #"2022" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Attribute", type text}, {"2021", type number}, {"2022", type number}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Attribute"}, "Attribute.1", "Value"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Custom", each [Attribute.1] &"."& [Attribute]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Attribute", "Attribute.1"})
in
    #"Removed Columns"

 

Or if you want this:

Eyelyn9_3-1657170122757.png

Then use "Pivot" after the steps above.

 


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.

Perfect - thank you!

Anonymous
Not applicable

You can select Attribute column and Unpivot the financial year columns (2021 and 2022) to get each attribute in single rows 

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
Top Kudoed Authors