Forum Discussion
Help Converting SCD0 to SCD2
I worked with this a little further today since posting the thread because just typing it out was a little bit of a nice rubber duck session and I got to the point where I have figured out how to actually pivot this into kind of the right place but now I need to fill down empty values where the previous value did not change.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZFNC4JAEIb/Suw5qN2E6BjZJUwk+jiIhzHHWtLdWMfAf59ZQdYmXnaHmedhX3bCkAVGX9FQtdAJsiGbExkZl4TLNMUjyRu6QK2BBwWtdSJTicln34e8xe0hK5FFw5BxPq0HfMRHYtyU/s7z6msf1MeqTKpPSjSYEF/1Bk9SK8gGa1BwQlO3Fmcji6cqZtYHLFIAeafSZDqAMaienDP+z211jhfo5CwRXIzNW+J9JU8W3c5v8EmfT/9D2RJUColeG3WcniHsnG2bUj0yRXc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"PropertyCode", Int64.Type}, {"AttributeEffectiveDate", type date}, {"AttributeLastModified", type text}, {"AttributeName", type text}, {"AttributeValue", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type1", {"AttributeEffectiveDate", "PropertyCode"}, {{"Partition", each _, type table [PropertyCode=nullable number, AttributeEffectiveDate=nullable date, AttributeLastModified=nullable text, AttributeName=nullable text, AttributeValue=nullable text]}}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Grouped Rows", "Partition", {"AttributeLastModified", "AttributeName", "AttributeValue"}, {"AttributeLastModified", "AttributeName", "AttributeValue"}),
#"Pivoted Column" = Table.Pivot(#"Expanded Custom", List.Distinct(#"Expanded Custom"[AttributeName]), "AttributeName", "AttributeValue"),
#"Sorted Rows" = Table.Sort(#"Pivoted Column",{{"PropertyCode", Order.Ascending}, {"AttributeEffectiveDate", Order.Ascending}})
in
#"Sorted Rows"
So what I need next is a conditional fill down when the property code is the same, in this case Judy in the VP column needs filled down but only because it's the same property code (117). In the larger data set there will be lots of nulls after values that would not get filled down because there is no previous value for that property.
Also, the same point applies to then how would I use this in the relational diagram to leverage a relationship between the date table/slicer and this new table to automatically handle the history so there is no need to write in extra code to all my DAX measures.
Thanks!