Power BI使用两个不同表中的日期测量逾期订单

时间:2018-01-25 23:14:51

标签: powerbi

请求:计算逾期的已购买订单数。应用过滤器时重新计算。

背景:有3个表:

  • Purchase_Orders包含订单[承诺日期],
  • Received_Orders包含[收到日期],
  • 包含唯一采购订单编号的PO_DIM。

关系:** Purchase_Orders -1 PO_DIM 1 - Received_Orders

衡量Sudo代码:

 1. CountRows
 2. Filter for rows where Purchase_Orders[Promised Date] is not Blank()
 3. Filter for rows where Received_Orders[Received Date] is Blank()
 4. Filter for rows where Purchase_Orders[Promised Date] < Today()

你会如何解决?

Link to my code and error

1 个答案:

答案 0 :(得分:0)

我会将3个过滤器需求转换为一个FILTER函数,使用RELATED来测试其他表中的列,如:

Count PO Pastdue =
CALCULATE (
    COUNTROWS ( 'PO_DIM' ),
    FILTER (
        'PO_DIM',
        NOT ( ISBLANK ( RELATED ( Purchase_Orders[Promised Date] ) ) )
            && ISBLANK ( RELATED ( Received_Orders[Received Date] ) )
            && RELATED ( Purchase_Orders[Promised Date] ) < TODAY ()
    )
)