Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powerbi 从不同表的两列中添加列Power BI_Powerbi_Dax_M - Fatal编程技术网

Powerbi 从不同表的两列中添加列Power BI

Powerbi 从不同表的两列中添加列Power BI,powerbi,dax,m,Powerbi,Dax,M,我想添加一个从不同表的两列计算得出的列: 表1: Date ; target; 19/10/2018; 52 表2: Product; Duration; P1; 1; P2; 3; P3; 4; 我想要这样的东西 Product; Duration; New Column P1; 1; (52/(1+3+4)*1) P2;

我想添加一个从不同表的两列计算得出的列:

表1:

  Date   ;    target;   
  19/10/2018;  52
表2:

Product; Duration;  
P1;             1;    
P2;             3;  
P3;             4;
我想要这样的东西

Product; Duration;  New Column  
P1;             1;  (52/(1+3+4)*1) 
P2;             3;  (52/(1+3+4)*3)    
P3;             4;  (52/(1+3+4)*4)

使用DAX,尝试将此列作为表2的新列:

New Column = VALUES('table1'[target])/SUM(table2[ Duration])*'table2'[ Duration]
VALUES函数将在这里工作,因为
'table1'[target]

当您将表1扩展为更多日期和目标时,如下所示:

可以使用LOOKUPVALUE函数检索特定日期的目标:

New Column =
LOOKUPVALUE ( Table1[target], Table1[Date], DATE ( 2018, 10, 19 ) )
    / SUM ( table2[ Duration] )
    * 'table2'[ Duration]
或目标表格的最新日期:

New Column =
LOOKUPVALUE ( Table1[target], Table1[Date], MAX ( 'Table1'[Date] ) )
    / SUM ( table2[ Duration] )
    * 'table2'[ Duration]