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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors