Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have the following problem. I want to transform the data from this format:
To this format:
Does anybody know how to complete this transformation in power query or DAX?
This is how I would do it. I am not a expert just a beginner.
Make your data into an Excel Table. You can name your table whatever you like.
Then using the Data Tab, select From Table/Range
Now you have one copy of the Table. Duplicate this in Power Query to have 4 tables. Name they however you want.
Format them to have only the one set of data per table. Here is the code:
RawData1
let
Source = Excel.CurrentWorkbook(){[Name="RawData"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Date1", type datetime}, {"Date2", type datetime}, {"Date3", type datetime}, {"Date4", type datetime}, {"D1", Int64.Type}, {"D2", Int64.Type}, {"D3", Int64.Type}, {"D4", Int64.Type}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"ID", "Date1", "D1"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns",{{"Date1", "Dates"}, {"D1", "D"}})
in
#"Renamed Columns"
RawData2
let
Source = Excel.CurrentWorkbook(){[Name="RawData"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Date1", type datetime}, {"Date2", type datetime}, {"Date3", type datetime}, {"Date4", type datetime}, {"D1", Int64.Type}, {"D2", Int64.Type}, {"D3", Int64.Type}, {"D4", Int64.Type}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"ID", "Date2", "D2"}),
#"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns",{{"Date2", "Dates"}, {"D2", "D"}})
in
#"Renamed Columns"
ETC....
Then Append to New to get your data:
let
Source = Table.Combine({RawData1, RawData2, RawData3, RawData4}),
#"Sorted Rows" = Table.Sort(Source,{{"ID", Order.Ascending}})
in
#"Sorted Rows"
Close and Load the Power Query Editor.