You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将Excel Aggregate函数转换为Power BI DAX,按工作组获取最小日期

在Power BI中用DAX实现按工作组获取最小日期

因为表A(group_work_sch)和表B(Schedule of types of work)已建立一对多关联,你可以通过以下两种方式在表A中添加计算列,获取对应工作组的最小开始/结束日期:

方法一:利用已有的关系(推荐)

直接使用RELATEDTABLE获取当前行关联的表B数据,再取最小值:

最小开始日期列

Min Start Date = MINX(RELATEDTABLE('Schedule of types of work'), 'Schedule of types of work'[Start Date])

或使用CALCULATE结合MIN:

Min Start Date = CALCULATE(MIN('Schedule of types of work'[Start Date]), RELATEDTABLE('Schedule of types of work'))

最小结束日期列

Min End Date = MINX(RELATEDTABLE('Schedule of types of work'), 'Schedule of types of work'[End Date])

或:

Min End Date = CALCULATE(MIN('Schedule of types of work'[End Date]), RELATEDTABLE('Schedule of types of work'))

方法二:手动筛选匹配行(适用于关联失效场景)

如果关联未正确生效,可通过FILTER手动匹配Section和Group of works字段:

最小开始日期列

Min Start Date = CALCULATE(
    MIN('Schedule of types of work'[Start Date]),
    FILTER(
        'Schedule of types of work',
        'Schedule of types of work'[Section] = group_work_sch[Section] &&
        'Schedule of types of work'[Group of works] = group_work_sch[Group of works]
    )
)

最小结束日期列

Min End Date = CALCULATE(
    MIN('Schedule of types of work'[End Date]),
    FILTER(
        'Schedule of types of work',
        'Schedule of types of work'[Section] = group_work_sch[Section] &&
        'Schedule of types of work'[Group of works] = group_work_sch[Group of works]
    )
)

以上两种方式的逻辑和你Excel中AGGREGATE公式一致:先筛选出与当前工作组匹配的表B行,再提取最小日期值。

内容的提问来源于stack exchange,提问作者Xazratxon Sultonxonov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 00:50:56