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
Algonar
New Member

Split column into X by value in another column

Hi everyone,

 

I have a set of data with multiple columns including 2 date-specific columns. 2 of the other columns include:

 

1. Value

2. Value type

 

Value type can be gross, cost or net

 

I want to split column "Value" into these 3 types, while retaining the date details so that instead of having

TypeDateValue
GrossJan 110
CostJan 16
NetJan 14

 

I'll have

 

DateGrossCostNet
Jan 11064

 

This is the desired outcome.

 

Right now, when splitting into 3 columns manually, I get multiple rows for the same date with 0 in other values, i.e.:

 

DateGrossCostNet
Jan 11000
Jan 1060
Jan 1004

 

Can anyone help get to the desired outcome?

 

Thank you!

1 ACCEPTED SOLUTION

Hi @Algonar ,
Here are the pics for pivoting your table. in reverse order.
Original table, change column order, pivot column.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 

Pivot and resultPivot and result23.PNG2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Nathaniel_C
Super User
Super User

Hello @Algonar ,
The best way to do this is in power query by going to power query and pasting the code below into the advanced editor for a blank query.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wci/KLy5W0lEy1PVKzAPRBkqxOtFKzvnFJUiiZmBBv1RkMROl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Type = _t, Date = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Type", type text}, {"Date", type date}, {"Value", Int64.Type}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Changed Type",{"Type", "Date", "Value"}),
    #"Pivoted Column" = Table.Pivot(#"Reordered Columns", List.Distinct(#"Reordered Columns"[Type]), "Type", "Value", List.Sum)
in
    #"Pivoted Column"

 


Let me know if you have any questions.

If this solves your problems, mark it as the solution, so that others can easily find it. Congratulations 👍are also nice.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @Algonar ,
Here are the pics for pivoting your table. in reverse order.
Original table, change column order, pivot column.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 

Pivot and resultPivot and result23.PNG2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you Nathaniel!

Hi @Algonar - you are welcome!
Let me recommend Supercharge Power BI, and the latest version of M is for Data Monkey, if you will be working in this field...on Amazon for less than 30 each.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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