Power BI 自定义列可根据条件计算运行总计

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

我在多个订单中得到了一个包含“组件”和所需数量“ToIssQty”的表格,已按组件和所需日期排序,需要在组件上每次机会添加一个包含运行总计的列

在此输入图片描述

我使用了以下公式,但是它只返回每个组件的总数,仍然需要显示每行的增量

RunTotalToIss = 
CALCULATE (
    SUM (TBL_WorkOrder_Detail[ToIssQty]),
    FILTER(
        TBL_WorkOrder_Detail,
        TBL_WorkOrder_Detail[Component]
            = EARLIER(TBL_WorkOrder_Detail[Component])
    )
)

在此输入图片描述

powerbi dax
2个回答
0
投票

也许尝试这样的事情:

SUMX (
    FILTER (
        TBL_WorkOrder_Detail,
        TBL_WorkOrder_Detail[Component] = EARLIER ( TBL_WorkOrder_Detail[Component] )
            && TBL_WorkOrder_Detail[Date] <= EARLIER ( TBL_WorkOrder_Detail[Date] )
    ),
    TBL_WorkOrder_Detail[ToIssQty]
)

0
投票

你可以尝试用下面这个测量-

RunTotalToIss = 

var this_row_component = min(TBL_WorkOrder_Detail[Component])
var this_row_releasedDate = min(TBL_WorkOrder_Detail[releasedDate])

return
CALCULATE (
    SUM (TBL_WorkOrder_Detail[ToIssQty]),
    FILTER(
        ALL(TBL_WorkOrder_Detail),
        TBL_WorkOrder_Detail[Component] = this_row_component
            && TBL_WorkOrder_Detail[releasedDate] < this_row_releasedDate
    )
)
© www.soinside.com 2019 - 2024. All rights reserved.