我需要汇总dax表并按从上一个EffectiveDate
起5个月的日期范围对其进行过滤,该日期为2019年7月27日
所以我的dax表达式:
TestTable1 =
VAR LastEffDate = LASTDATE(fact_Premium[EffectiveDate]) // -- 7/27/2019
RETURN
SUMMARIZE(
FILTER(dim_Date, DATEDIFF(DATEADD(STARTOFMONTH(LastEffDate), -5,MONTH), ENDOFMONTH(LastEffDate), MONTH)),
dim_Date[Year Month],
"Premium", [Ttl WP]
)
但是由于某种原因,它为我带来了数据集中所有年份的数据:
我也尝试过:
TestTable1 =
VAR LastEffDate = LASTDATE(fact_Premium[EffectiveDate]) // -- 7/27/2019
RETURN
SUMMARIZE (
FILTER (
dim_Date,
DATESBETWEEN(dim_Date[Date],
DATE(2019,5,1),
DATE(2019,6,1)
)
),
dim_Date[Year Month],
"Premium", [Ttl WP]
)
但这给我一个错误:
A table of multiple values was supplied where a single value was expected.
我在这里想念东西吗?
答案 0 :(得分:2)
您的过滤器表达式应使用DATESBETWEEN而不是datediff:
TestTable1 =
VAR LastEffDate = LASTDATE(fact_Premium[EffectiveDate]) // -- 7/27/2019
RETURN
SUMMARIZE (
FILTER (
dim_Date,
DATESBETWEEN(
//expression for start date,
//expression for end date
)
),
dim_Date[Year Month],
"Premium", [Ttl WP]
)
答案 1 :(得分:0)
我认为您仍然缺少汇总保费的信息,
SUM(Ttl WP)
TestTable1 =
VAR LastEffDate =
LASTDATE ( fact_Premium[EffectiveDate] ) // -- 7/27/2019
RETURN
SUMMARIZE (
FILTER (
dim_Date,
DATESBETWEEN ( dim_Date[Date], DATE ( 2019, 5, 1 ), DATE ( 2019, 6, 1 ) )
),
dim_Date[Year Month],
"Premium", SUM ( [Ttl WP] ) ---- Need to aggregate here
)