我想根据属性名称获取前一天的值,因此将两级过滤器应用于我的计算列。 目前,我坚持使用下面的公式给我空白列。
Column = CALCULATE(
MAX(useractivity[Value]),
FILTER(
useractivity,
useractivity[Dates]=EARLIER(useractivity[Dates])-1
),
FILTER(
an IFS function maybe?
))
我想要以下输出:
+------------------+-----------+---------+----------------+
| Dates | Attribute | Value | Previous_Value |
+------------------+-----------+---------+----------------+
| 31 december 2018 | active | 100,000 | 80,000 |
| 31 december 2018 | inactive | 50,000 | 40,000 |
| 29 december 2018 | active | 80,000 | ... |
| 29 december 2018 | inactive | 40,000 | ... |
+------------------+-----------+---------+----------------+
答案 0 :(得分:1)
这类似于我的答案here。计算上一个日期,然后进行查找。
Previous_Value =
VAR PrevDay =
CALCULATE (
LASTDATE ( useractivity[Dates] ),
ALLEXCEPT ( useractivity, useractivity[Attribute] ),
useractivity[Dates] < EARLIER ( useractivity[Dates] )
)
RETURN
LOOKUPVALUE (
useractivity[Value],
useractivity[Dates], PrevDay,
useractivity[Attribute], useractivity[Attribute]
)
修改
作为一项措施,您需要进行一些细微调整,
Previous_Value =
VAR PrevDay =
CALCULATE (
LASTDATE ( useractivity[Dates] ),
FILTER(
ALLEXCEPT ( useractivity, useractivity[Attribute] ),
useractivity[Dates] < MAX( useractivity[Dates] )
)
)
RETURN
LOOKUPVALUE (
useractivity[Value],
useractivity[Dates], PrevDay,
useractivity[Attribute], MAX(useractivity[Attribute])
)