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.
Hi guys,
I have faced problem to solver this case:
I have the table below:
Order_ID | Mov | Date |
100500501 | 105 | 10/08/2020 |
100500501 | 105 | 11/08/2020 |
100500501 | 105 | 12/08/2020 |
100500501 | 105 | 13/08/2020 |
100500501 | 105 | 14/08/2020 |
I want to convert in this table:
Order_ID | Date1 | Date2 | Date3 | Date4 | Date5 |
100500501 | 10/08/2020 | 11/08/2020 | 12/08/2020 | 13/08/2020 | 14/08/2020 |
Is it possible in PowerBI?
Thanks!
Solved! Go to Solution.
Hi @William_Moreno ,
We can use some transformations in Power Query Editor to meet your requirement.
1. Copy the table and delete the Mov column.
2. Group the Order_ID column.
3. Add a custom column to get the Date column.
4. Extract the Custom column by comma.
5. At last, split the column.
The whole M query as following,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMAUhQyUdINsUSBoZGBnoW+gbGijF6uCTNyQgb0RA3piAvAmKvBFY3gwmb6hviF/aCL+0MX5pAnabKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Order_ID = _t, Mov = _t, Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Mov"}),
#"Grouped Rows" = Table.Group(#"Removed Columns", {"Order_ID"}, {{"Data", each _, type table [Order_ID=nullable text, Date=nullable date]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.Column([Data],"Date")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Removed Columns1" = Table.RemoveColumns(#"Extracted Values",{"Data"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns1", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3", "Custom.4", "Custom.5"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Order_ID", Int64.Type}, {"Custom.1", type date}, {"Custom.2", type date}, {"Custom.3", type date}, {"Custom.4", type date}, {"Custom.5", type date}})
in
#"Changed Type1"
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
Hi @William_Moreno ,
How about the result after you follow the suggestions mentioned in my original post?
Could you please provide more details or expected result about it If it doesn't meet your requirement?
If you've fixed the issue on your own please kindly share your solution. If the above posts help, please kindly mark it as a solution to help others find it more quickly.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @William_Moreno ,
We can use some transformations in Power Query Editor to meet your requirement.
1. Copy the table and delete the Mov column.
2. Group the Order_ID column.
3. Add a custom column to get the Date column.
4. Extract the Custom column by comma.
5. At last, split the column.
The whole M query as following,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMAUhQyUdINsUSBoZGBnoW+gbGijF6uCTNyQgb0RA3piAvAmKvBFY3gwmb6hviF/aCL+0MX5pAnabKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Order_ID = _t, Mov = _t, Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Mov"}),
#"Grouped Rows" = Table.Group(#"Removed Columns", {"Order_ID"}, {{"Data", each _, type table [Order_ID=nullable text, Date=nullable date]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.Column([Data],"Date")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Removed Columns1" = Table.RemoveColumns(#"Extracted Values",{"Data"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns1", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3", "Custom.4", "Custom.5"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Order_ID", Int64.Type}, {"Custom.1", type date}, {"Custom.2", type date}, {"Custom.3", type date}, {"Custom.4", type date}, {"Custom.5", type date}})
in
#"Changed Type1"
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
@William_Moreno , Create a column(Sub category based on order id) Rank and and append that with Date
Date new = "Date " & [RanK]
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...
Use pivot table
https://databear.com/power-bi-pivot-and-unpivot-columns/
Hope it resolves your issue? Did I answer your question? Mark my post as a solution! Appreciate your Kudos, Press the thumbs up button!! Linkedin Profile |
Thank you for your answer but, the corvesion has to be developed in another table!
It means that the vertical table is the table 1 e horizontal table is table 2 in power bi.
Thanks in advanced.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |