我想设置一个报告,使用我们拥有的“最佳可用”数据向最终用户呈现数据。我计划维护 3 个数据库,每个数据库的结构都相同。将会出现“初步数据”、“最终数据未验证”和“最终数据已锁定”。
我希望能够报告最佳可用数据。因此,如果单元格中有“最终数据锁定”,请使用它,否则使用“最终数据未经验证”,否则使用“初步数据”
首先,我可以创建一个新表并使用以下代码手动添加列,但是有没有一种更简单的方法来创建整个表,而无需我为每一列编写代码? (会有超过100列)
A = if(isblank(lookupvalue('Final Data Locked'[A],'Final Data Locked'[Test Data],'Data To Use Table'[Test Data])),if(isblank(lookupvalue('Final Data Unverified'[A],'Final Data Unverified'[Test Data],'Data To Use Table'[Test Data])),lookupvalue('Prelim Data'[A],'Prelim Data'[Test Data],'Data To Use Table'[Test Data]),lookupvalue('Final Data Unverified'[A],'Final Data Unverified'[Test Data],'Data To Use Table'[Test Data])),lookupvalue('Final Data Locked'[A],'Final Data Locked'[Test Data],'Data To Use Table'[Test Data]))
其次,这可能是一件好事,如果用户可以切换报告以排除“初步数据”和/或“最终数据未经验证”,这样他们只能看到带有“最终数据锁定”的报告,那就太棒了。 ”有没有一种简单的方法可以实现这一目标? 我过去曾通过在度量上使用选定的值来完成,但由于目前它是通过计算列或可能计算表,不确定是否可以实现?
您可以基于三个可用表创建一个新表,输出如下-
这是新表的高级查询 -
let
Append1 = let
Source = Table.Combine({#"Prelim Data", #"Final Data Unvarified", #"Final Data Locked"}),
#"Reordered Columns" = Table.ReorderColumns(Source,{"Test Data", "Table Priority", "Sum of A", "Sum of B", "Sum of C", "Sum of D"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Reordered Columns", {"Test Data", "Table Priority"}, "Attribute", "Value"),
#"Sorted Rows" = Table.Sort(#"Unpivoted Other Columns",{{"Test Data", Order.Ascending}, {"Attribute", Order.Ascending}}),
#"Added Custom" = Table.AddColumn(#"Sorted Rows", "min_priority", each if [Value] = "" or [Value] is null then null else [Table Priority]),
#"table_1" = Table.RemoveColumns(#"Added Custom",{"Table Priority"}),
#"table_2" = Table.Group(#"table_1", {"Test Data", "Attribute"}, {{"min_priority_new", each List.Min([min_priority]), type nullable number}}),
#"Merged Queries" = Table.NestedJoin(
table_1, {"Test Data","Attribute", "min_priority"},
table_2, {"Test Data","Attribute", "min_priority_new"},
"new_table", JoinKind.Inner
)
in
#"Merged Queries",
#"Removed Columns" = Table.RemoveColumns(Append1,{"new_table", "min_priority"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute]), "Attribute", "Value")
in
#"Pivoted Column"