为表/矩阵视觉效果创建 Dax 查询

问题描述 投票:0回答:1

我有以下表格:

交易对手表

Counterparty
foo 
boo
fizz
buzz
huzz

表1数据:

Counterparty Commodity DealType   StartDate  FloatPrice  MTMValue
      foo       bar      Buy  07/01/2024       18.73        10
      fizz      bar      Buy  09/01/2024       17.12        10
      fizz      bar      Buy  10/01/2024       17.76        10
      fizz      bar      Buy  11/01/2024       18.72        10
      fizz      bar      Buy  12/01/2024       19.47        10
      foo   ab cred      Buy  01/01/2025       20.26        10
      boo       baz     Sell  01/01/2025       21.04        10
      boo       baz     Sell  01/01/2025       22.23        10
      fizz      baz     Sell  01/01/2025       11.89        10
      fizz      baz     Sell  01/01/2025       12.33        10
      foo       baz     Sell  01/01/2025       14.78        10
      foo       baz     Sell  01/01/2025       18.23        10
      boo      rins     Sell  01/01/2025       16.43        10
      boo   ab cred     Sell  01/01/2025       12.21        10

表2数据

Counterparty Commodity DealType   StartDate  FloatPrice  MTMValue
      foo       bar      Buy  07/01/2024       18.73        10
      fizz      bar      Buy  09/01/2024       17.12        10
      fizz      bar      Buy  10/01/2024       17.76        10
      fizz      bar      Buy  11/01/2024       18.72        10
      fizz      bar      Buy  12/01/2024       19.47        10
      foo   ab cred      Buy  01/01/2025       20.26        10
      boo       baz     Sell  01/01/2025       21.04        10
      boo       baz     Sell  01/01/2025       22.23        10
      fizz      baz     Sell  01/01/2025       11.89        10
      fizz      baz     Sell  01/01/2025       12.33        10
      foo       baz     Sell  01/01/2025       14.78        10
      foo       baz     Sell  01/01/2025       18.23        10
      boo      rins     Sell  01/01/2025       16.43        10
      boo   ab cred     Sell  01/01/2025       12.21        10

作为示例,表 1 和表 2 完全相同。实际上,它们的结构相同,但最后一列具有不同的值。

如何编写查询来基于这 3 个表创建如下表:

对于商品 = BAR

Counterparty  Table1 Sum  Table2 Sum
   foo            10          10
   boo            0           0
   fizz           40          40
   buzz           0           0
   huzz           0           0       

我将在桌子上安装一个切片机来过滤商品

powerbi
1个回答
0
投票

你可以创建一个昏暗的桌子

Table = DISTINCT(Table1[Commodity])

创建 4 个表之间的关系。 enter image description here

然后使用新的昏暗表中的商品列作为过滤器并创建两个度量

table1 sum = sum(Table1[MTMValue])+0
table2 sum = sum(Table2[MTMValue])+0

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.