March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello All,
Back to basics for me on this one!
Using BI for a while now and have created plenty of reports, most of which I have been using SQL data, which appears to be very user friendly with the format when importing into BI.
However, I have been working with Excel sheets most recently and have come across the same issues with the majority of them.. I am sure there is a very simple solution to this as this is a very common format for spreadsheets, but just can't get my head round it!
Above is the prime example of the type of data I am trying to bring into BI through Excel.
As the data is input into SQL line-by-line there is always an individual date stamp next to each record, compared to the Excel sheet which will only have 1 date, which is set at the column header, to cover any number of records input into the table.
This then makes it awkward when bringing the data into BI, for instance when attempting to import a slicer so that I can select my specified days. With the SQL data this would have been as straight forward as dropping the date column into the slicer, however, how can I achieve the same result with the format in which the example Excel sheet is set out? (multiple dates in their own columns)
Ultimately, what I am looking to achieve is a simple graph to show the 'fruit' as the X-axis and then filter by date (in this case, filter by a specified date column)
(As example below)
Thank you in advance!
Solved! Go to Solution.
With your example, try unpivoting the date columns, like this:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElV0lEyNAASxgZKsTrRSv5FiXnpcEEjiGBAamIRhAcWBwk5JeYBIbJgLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"1/1/2016" = _t, #"2/1/2016" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"1/1/2016", Int64.Type}, {"2/1/2016", Int64.Type}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"(blank)", "Fruit"}}), #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Renamed Columns", {"Fruit"}, "Attribute", "Value") in #"Unpivoted Columns"
You should end up with a table like:
You don't have to write the "M" code, just select your date columns (all of them) and right click and choose "Unpivot Columns"
With your example, try unpivoting the date columns, like this:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElV0lEyNAASxgZKsTrRSv5FiXnpcEEjiGBAamIRhAcWBwk5JeYBIbJgLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"1/1/2016" = _t, #"2/1/2016" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"1/1/2016", Int64.Type}, {"2/1/2016", Int64.Type}}), #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"(blank)", "Fruit"}}), #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Renamed Columns", {"Fruit"}, "Attribute", "Value") in #"Unpivoted Columns"
You should end up with a table like:
The example you have shown just there looks spot on.
I'll give it a go and see how I get on
Thanks for the quick response!
You don't have to write the "M" code, just select your date columns (all of them) and right click and choose "Unpivot Columns"
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |