Forum Discussion
Deliminate columns but keep like values together
- 3 years ago
No problem. Here's how I think you should be structuring your table for 1) maximum efficiency and 2) ease of reporting:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XY3BCoMwEER/Jew5F9svkAbvnkMOkg4aWBNJVtG/79JLqbd5MDPPe+rI0rhPnOTSNHAp1QzplL3Cmr7GJQmi0sQUrKeHll5l3RiCjNYUHVqas3E4wGVbkeXbfP6OrblN+veCihxV8WekED4=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project Name" = _t, #"Project Info" = _t, Design = _t]), chgTypes = Table.TransformColumnTypes(Source,{{"Project Name", Int64.Type}, {"Project Info", type text}, {"Design", type text}}), // Relevant steps -----> unpivOthCols = Table.UnpivotOtherColumns(chgTypes, {"Project Name"}, "improvArea", "Value"), addImprovItem = Table.AddColumn(unpivOthCols, "improvItem", each Text.Split([Value], ", ")), expandImprovItem = Table.ExpandListColumn(addImprovItem, "improvItem"), // <----- Relevant steps remOthCols = Table.SelectColumns(expandImprovItem,{"Project Name", "improvArea", "improvItem"}) in remOthColsThis gives us the following fact table output structure:
This fact structure then makes calculations over the whole table very easy, for example:
_noofProjects = DISTINCTCOUNT(factProjects[Project Name]) _noofImprovAreas = DISTINCTCOUNT(factProjects[improvArea]) _noofImprovItems = COUNTROWS(factProjects)These measures can be used in visuals with any of your fact table columns to provide the insights you're looking for. The way you were asking for your data to be structured previously would have required a separate measure for each [Project Info ~] column, and each [Design ~] column, which would have quickly become difficult to maintain, challenging to get visuals to show what you wanted, and impossible for improvement areas and improvement items to be used in slicers etc.
Above the fact table you would likely have a dimProject dimension table which would have a single row per [Project Name], and would contain info such as Project Manager, Client, Project Start Date/End Date etc. which would be related to this fact table on Dimension[Project Name] ONE : MANY Fact[Project Name], but this is getting slightly beyond scope of this post I think.
Pete