简体   繁体   English

一张表中的动态行比较-DAX / M语言/ Power BI

[英]Dynamic row comparison in one table - DAX / M language / Power BI

Is this possible? 这可能吗?

I've got a table, with a column containing the version of product (for example: fast car ). 我有一个表格,其中包含产品版本的列(例如: fast car )。 Every version has a list of parts (for example: color ). 每个版本都有一个零件列表(例如: color )。 Every part has a number of values (for example: red ). 每个部分都有许多 (例如: red )。

VERSION PART PART_VALUE VERSION1 PART1 PART_VALUE1 VERSION1 PART2 PART_VALUE2 VERSION1 PART3 PART_VALUE3 VERSION2 PART2 PART_VALUE2 VERSION2 PART3 PART_VALUE3 VERSION2 PART4 PART_VALUE4 VERSION3 PART1 PART_VALUE1 VERSION3 PART2 PART_VALUE2 VERSION3 PART3 PART_VALUE4

Now I want to select - in Fragmentator or in some other checkbox - Version1 and Version2 and the results should be: 现在,我想在“ Fragmentator”或其他复选框中选择“ Version1”和“ Version2” ,结果应为:

"ONLY DIFFENCES BETWEEN VERSION1 AND VERSION2"
VERSION1 PART1 PART_VALUE1 VERSION2 PART4 PART_VALUE4

or after selecting Version1 and Version3 the results should be: 或在选择Version1Version3之后 ,结果应为:

"ONLY DIFFENCES BETWEEN VERSION1 AND VERSION3"
VERSION1 PART3 PART_VALUE3 VERSION3 PART3 PART_VALUE4

Here's an M query which should do what you want: 这是一个M查询,它应该执行您想要的操作:

(V1, V2) =>
let
    Source = MyTable,
    First = Table.SelectRows(Source, each ([VERSION] = V1)),
    Second = Table.SelectRows(Source, each ([VERSION] = V2)),
    #"First Unique" = Table.NestedJoin(First,{"PART", "PART_VALUE"},Second,{"PART", "PART_VALUE"},"Second",JoinKind.LeftAnti),
    #"Second Unique" = Table.NestedJoin(Second,{"PART", "PART_VALUE"},First,{"PART", "PART_VALUE"},"First",JoinKind.LeftAnti),
    Combine = Table.Combine({#"First Unique", #"Second Unique"}),
    #"Removed Columns" = Table.RemoveColumns(Combine,{"Second", "First"})
in
    #"Removed Columns"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Power Bi - 在不同表(参考表)中查找值并返回真 - Power Bi - Lookup for A Value in Different Table (Reference Table) and Return True 我正在编写比较日期的代码。首先,如果第一个更大(或)打印第二个,如果第二个更大,如果日期无效则出错 - I'm writing code for comparison of date.print First,if first one is greater (or) print Second,if second one is greater,Error if the dates are invalid 具有NULL值的表比较 - Table Comparison with NULL value SQL与下一行中的值进行比较 - SQL Comparison to a value in the next row R 中 dataframe 的逐行比较 - Row wise comparison of a dataframe in R 我需要将上排与下排进行比较,因此我可以创建一个空行或下排的内容,具体取决于该比较 - I need to compare the superior row with the one below, so I can create an empty one or with the infeiror's content, depending on that comparison 一种哈希函数和RSA的比较 - Comparison of one hash function and RSA 一个数组列表中的比较差异对象 - comparison difference object in one arraylist SQL Server 2012-根据行与行的比较更新列 - SQL Server 2012 - updating a column based on row to row comparison 有没有办法将数据表中的一个给定行与一组中的其他行进行比较? - Is there any way to compare one given row in a data table with other rows withing a group?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM