简体   繁体   English

Power BI DAX:将一列求和到当前行

[英]Power BI DAX: Sum a column up to the current row

I have a table with a the following structure:我有一个具有以下结构的表:

 2 10/1/2019 
 1 10/12/2019
 0 10/13/2019
 3 11/1/2019

each row has a date and an integer assigned to the date.每行都有一个日期和一个分配给该日期的 integer。 I want to create a column with the sum up to the date of the row: (like so)我想创建一个总和到行日期的列:(像这样)

2 10/1/2019 2
1 10/12/2019 3
0 10/13/2019 3
3 11/1/2019 6

this is the DAX I tried:这是我尝试过的 DAX:

Count = 
    var ThisDate = Table[Date]
    var t = SUMX(FILTER(Table, Table[Date]<=ThisDate),[number])
return t

but the results Im getting are far off what I described, what is wrong with my expression?但是我得到的结果与我描述的相差甚远,我的表达有什么问题?

You can also calculate function here:您也可以在这里计算 function:

Count = 
VAR ThisDate = Table[Date] 
RETURN 
        CALCULATE(SUM(Table[Number]),FILTER(Table,ThisDate >= Table[Date]))

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

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