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

如何创建DAX度量值或Power Query流程获取同日期时间其他行对应值

Power Query 实现 transactions 表规则计算及清洗方案

步骤1:新增EUR_amt自定义列

进入Power Query编辑器打开transactions表,添加自定义列,公式如下:

let
    currentDatetime = [datetime], // 请替换为你表中实际的日期时间字段名
    currentCurrency = [currency],
    currentType = [type],
    // 匹配同时间的EUR币种行的amount值
    eurAmount = try Table.Max(Table.SelectRows(#"上一步步骤名", (x)=> x[datetime] = currentDatetime and x[currency] = "EUR"), "datetime")[amount] otherwise 0
in
    if currentCurrency <> "EUR" and currentType = "trade" then -eurAmount else 0

注意:请将公式中的datetime替换为你表中实际存储日期时间的字段名,#"上一步步骤名"替换为你当前操作前一步的查询步骤名称。

步骤2:按日期时间分组

如果需要按日期时间聚合数据,可按以下操作:

  • 选中日期时间字段,点击「转换」选项卡下的「分组依据」
  • 配置分组规则:
    • 新列名可自定义为聚合后金额,操作选择「求和」,求和列为刚新增的EUR_amt
    • 如需保留其他字段,可在高级分组中添加其他需要保留的字段作为分组维度

步骤3:删除指定无效行

添加筛选步骤,过滤掉同时满足以下两个条件的行:

  • currency = "EUR"
  • EUR_amt = 0

备选:DAX计算列实现方案

如果你不需要Power Query方案,可直接用DAX新增计算列,公式如下:

EUR_amt = 
VAR currentDatetime = transactions[datetime]
VAR sameTimeEurAmt = CALCULATE(MAX(transactions[amount]), ALLEXCEPT(transactions, transactions[datetime]), transactions[currency] = "EUR")
RETURN
IF(
    transactions[currency] <> "EUR" && transactions[type] = "trade",
    -sameTimeEurAmt,
    0
)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.25 20:24:03