简体   繁体   English

POWER BI - 可以递归计算我的 dax 度量的解决方法?

[英]POWER BI - workaround possible for recursive calculation of my dax measure?

I have 2 tables on orders with the order validity date and in transit stock (stock reaching where the order will be serviced).我有 2 个订单表,其中包含订单有效期和在途库存(到达订单服务地点的库存)。

(using sample data to simplify for understanding) I am looking for a final calculation like this in my final table - (使用样本数据来简化理解)我正在我的最终表中寻找这样的最终计算 -

决赛桌

have done the calculation till column 4 in power BI在 Power BI 中计算到第 4 列

if this was in excel i could have simply done如果这是在 excel 我可以简单地完成

used_stock(2) = serviced(1) + used_stock(1)二手库存(2) = 已维修(1) + 二手库存(1)

avail_stock(2) = total_qty(2) - used_stock(2) avail_stock(2) = total_qty(2) - used_stock(2)

serviced(2) = min(order(2),avail_stock(2))服务(2)= min(订单(2),可用库存(2))

My base tables look like this -我的基表看起来像这样 -

order table -订单表 -

订单表

intransit table -中转表——

在途表

I have done the total_qty measure calculation by finding the cumulative sum of shipment quantity for the dates before selected value of order validity date.我通过查找订单有效期所选值之前的日期的装运数量累计总和来完成 total_qty 度量计算。

I am trying to do the rest of the measures but ending up in circular references.我正在尝试执行 rest 的措施,但最终以循环引用告终。 Is there a way I can do it?有什么办法可以做到吗?

edit -编辑 -

Clarifying it a bit more for the logic needed -为所需的逻辑进一步澄清它 -

let's say the 2nd order is 15 and the 2nd shipment reaches on 24th, then the base data and output table should look like this -假设第二个订单是 15,第二批货物在 24 日到达,那么基础数据和 output 表应该如下所示 -

新命令

新货

新的决赛桌

With present proposed solution the table will erroneously look like -使用目前提出的解决方案,表格将错误地看起来像-

建议表

Try with these below measures-尝试以下这些措施-

total_qty = 

VAR current_row_date = MIN('order'[order valid till date])

RETURN
CALCULATE(
    SUM(intrasit[quantity in shipment]),
    FILTER(
        ALL(intrasit),
        intrasit[expected date of reaching] < current_row_date
    )
)
used_stock = 

VAR current_row_date = MIN('order'[order valid till date])

RETURN
CALCULATE(
    SUM('order'[order quantity]),
    FILTER(
        ALL('order'),
        'order'[order valid till date] < current_row_date
    )
) + 0
avail_stock = [total_qty] - [used_stock]
serviced = 
IF(
    MIN('order'[order quantity]) <= [avail_stock],
    MIN('order'[order quantity]),
    [avail_stock]
)

Here is your final output-这是您的最终输出-

在此处输入图像描述

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM