Skip to content

Instantly share code, notes, and snippets.

@cbaragao
Created January 28, 2024 13:34
Show Gist options
  • Select an option

  • Save cbaragao/db1a94ffda8db02c87da58a5fb92a998 to your computer and use it in GitHub Desktop.

Select an option

Save cbaragao/db1a94ffda8db02c87da58a5fb92a998 to your computer and use it in GitHub Desktop.
let fnCreateMultiDimID =
(fact as table, dim as table) =>
let
// Get column names minus the first column on the dim table, which should be the id
Columns = List.Skip(Table.ColumnNames(dim),1),
// Join the tables
Join = Table.Join(fact, Columns, dim, Columns),
// Remove the columns in the fact table that are now stored in the dim table and keep the id
Remove = Table.RemoveColumns(Join, Columns)
in
Remove,
// Documentation
fnType = type function (fact as table, dim as table) as table
meta [
Documentation.Name = "fnCreateMultiDimID",
Documentation.LongDescription = "This function takes a fact and dim table and brings over the dim id and removes columns in the fact table."
]
in
Value.ReplaceType(fnCreateMultiDimID, fnType)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment