我有一个包含以下各列的表:
| Feature | Date | Update | hours|
|---------------------|------------------|-----------|------|
|General |2018-10-02 |V1 |0 |
|General |2018-10-02 |V1 |0 |
|General |2018-10-02 |V1 |0 |
|General |2018-10-02 |V1 |0 |
|General |2018-10-02 |V1 |0 |
|PvP |2018-10-02 |V1 |3 |
|PvP |2018-10-02 |V1 |2 |
|PvP |2018-10-02 |V1 |1 |
|PvP |2018-10-02 |V1 |1 |
|General |2018-10-02 |V1 |0 |
|General |2018-10-02 |V1 |7 |
|General |2018-10-02 |V1 |0 |
|General |2018-10-02 |V1 |0 |
|Visual |2018-10-02 |V1 |7 |
|General |2018-10-15 |V1 |0 |
|General |2018-10-15 |V1 |0 |
|General |2018-10-15 |V1 |0 |
|Visual |2018-10-15 |V1 |7 |
|Visual |2018-10-15 |V1 |2 |
|General |2018-10-16 |V1 |1 |
在本示例中,我想添加一个自定义列,该列可以根据以下条件来计算为每个功能执行的运行次数:
根据每天的功能计算分钟总和,并: 例如,如果今天的总和高于昨天的总和,则计为1次运行,否则计为零。
下面是一个例子
| Feature | Date | Update | hours|No of runs|
|---------------------|------------------|-----------|------|----------|
|General |2018-10-02 |V1 |0 |1
|General |2018-10-02 |V1 |0 |1
|General |2018-10-02 |V1 |0 |1
|General |2018-10-02 |V1 |0 |1
|General |2018-10-02 |V1 |0 |1
|PvP |2018-10-02 |V1 |3 |1
|PvP |2018-10-02 |V1 |2 |1
|PvP |2018-10-02 |V1 |1 |1
|PvP |2018-10-02 |V1 |1 |1
|General |2018-10-02 |V1 |0 |1
|General |2018-10-02 |V1 |7 |1
|General |2018-10-02 |V1 |0 |1
|General |2018-10-02 |V1 |0 |1
|Visual |2018-10-02 |V1 |7 |1
|General |2018-10-15 |V1 |0 |0
|General |2018-10-15 |V1 |0 |0
|General |2018-10-15 |V1 |0 |0
|Visual |2018-10-15 |V1 |7 |1
|Visual |2018-10-15 |V1 |2 |1
|General |2018-10-16 |V1 |1 |1
每个功能的运行计数器应从1开始。
到目前为止,我尝试使用以下公式,但给出的信息不正确:
运行次数= CALCULATE(COUNTA('table'[Feature]),Filter('Table','Table'[Feature] = EARLIER('Table'[Feature])&&'Table'[Date]> EARLIER('表格'[日期] &&'表格'[投资时间(小时)]>较早('表格'[投资时间(小时)])))
答案 0 :(得分:2)
不确定我是否已完全理解逻辑,但请尝试将其作为计算列:
No_of_runs =
VAR DateToday =
Table1[Date]
VAR MinutesToday =
CALCULATE (
SUM ( Table1[Time Invested (hours)] ),
FILTER (
ALLEXCEPT ( Table1, Table1[Feature] ),
Table1[Date] = DateToday
)
)
VAR MinutesYesterday =
CALCULATE (
SUM ( Table1[Time Invested (hours)] ),
FILTER (
ALLEXCEPT ( Table1, Table1[Feature] ),
Table1[Date] = DateToday - 1
)
)
RETURN
IF (
MinutesToday > MinutesYesterday,
1,
0
)
编辑:这是一个可行的示例PBIX文件; https://pwrbi.com/so_55588315/