如何在最短日期使用过滤器在Power BI度量中添加2列?

时间:2019-02-15 10:48:17

标签: powerbi dax

我有一个像这样的桌子:

Id  numbers_old  numbers_new  date
1    5              0         2019-02-13
1    8              3         2019-02-14
2    2              0         2019-02-13
2    12             10        2019-02-14
2    15             5         2019-02-15

我想要一个可以计算volume_total = (number_old where date=min(date)) + (numbers_new where date != min(date))的度量

如何通过Power BI措施实现它?

1 个答案:

答案 0 :(得分:0)

您可以编写度量:

volume_total = 
VAR DateMin = 
    MIN ( Table1[date] )
VAR SumOld = 
    CALCULATE ( 
        SUM ( Table1[numbers_old] ),
        Table1[date] = DateMin
    )
VAR SumNew = 
    CALCULATE ( 
        SUM ( Table1[numbers_new] ),
        Table1[date] <> DateMin
    )
RETURN
    SumOld + SumNew

工作示例PBIX文件:https://pwrbi.com/so_54707672/