我有两张桌子在工作。一个是一个大的数据集,大约有50列。第二个表是第一个数据集的Table.Schema()。
我正在尝试构建一个类似于Table.Profile()的数据质量报告,但需要更多的定制。但是,我甚至无法为每个源列重新创建Table.Profile的基本元素,如Counta或null计数。
如何使用架构Name值对架构名称表示的数据源列执行计数计算?有关所需输出,请参见下面的架构表,计算数据源中非空白值的数量。
注意:由于有大量的列,我希望构建这个公式,因此它是基于名称值的动态的,而不是将50+列名硬编码成公式。
数据源
ID | Status | Created | Modified
1 | Active | 1/1/19 | null
2 | null | 1/5/15 | 1/6/15
3 | Active | null | null模式
Name | Type | Counta
ID | Number | 3
Status | Text | 2
Created | Date | 2
Modified | Date | 1发布于 2019-08-23 18:54:18
我将给出使用count、非空计数和不同计数的示例,这样您就可以看到模式的几个实例。
我假设您的表数据位于一个名为Table的表中。下面是用于添加上述计数的完整高级编辑器视图。
let
srcTable = Table // This is an arg to all steps below, so useful to have here
,schema = Table.Schema(srcTable) // you've used this
,count =
Table.AddColumn( // self-descriptive
schema // the source table to add this new column to
,"Count" // the name of the new column we are adding
// below is a function to evaluate per row in the source table
// The way to reference a table column by name is
// Table.Column(table, "column"). That returns a list.
,each List.Count(Table.Column(srcTable, _[Name])))
,nonNullCount =
Table.AddColumn(
count
,"Non-null count"
,each List.NonNullCount(Table.Column(srcTable, _[Name])))
,distinctCount =
Table.AddColumn(
nonNullCount
,"Distinct Count"
,each List.Count(List.Distinct(Table.Column(srcTable, _[Name]))))
in
distinctCount实际上,我不会尝试重新实现Table.Profile。我将加入Table.Schema和Table.Profile的结果,然后添加额外的分析。
let
srcTable = Opportunity // This is an arg to all steps below, so useful to have here
,schema = Table.Schema(srcTable) // you've used this
,profile = Table.Profile(srcTable)
,schemaAndProfile =
Table.NestedJoin(
schema
,"Name"
,profile
,"Column"
,"profile"
)
,expandProfile =
Table.ExpandTableColumn(
schemaAndProfile
,"profile"
,{"Min", "Max", "Average", "StandardDeviation", "Count", "NullCount", "DistinctCount"}
,{"profile.Min", "profile.Max", "profile.Average", "profile.StandardDeviation", "profile.Count", "profile.NullCount", "profile.DistinctCount"})
in
expandProfile引用列与上面的示例相同,但这将在更健壮的状态下启动。
https://stackoverflow.com/questions/57630613
复制相似问题