在SUMMARIZE公式中添加IF语句

时间:2019-07-16 21:09:05

标签: powerbi dax

目标:

我想在查询中添加一个IF条件,但不确定如何。换句话说,将MAX表达式替换为下面的IF语句

IF条件为:

IF(
    'Data Model'[amount] = 'Data Model'[orderTotalPrice],
    'Data Model'[amount] - 'Data Model'[shipping_price] - 'Data Model'[total_tax],
    'Data Model'[amount]
)

我的查询:

VAR Summary =
 CALCULATETABLE(SUMMARIZE (
        'Data Model',
        'Data Model'[orderId],
        "MaxValue", CALCULATE (
            MAX ( 'Data Model'[amount] ),
            'Data Model'[kind] = "refund",
            'Data Model'[status] = "success"
        )
    ),USERELATIONSHIP ( 'Data Model'[trx_date], DateTable[Date] ))
RETURN
    SUMX ( Summary, [MaxValue] )

0 个答案:

没有答案