所有上下文删除不适用
以下措施无法正常工作:
VAR lt_MAX_DATE =
FILTER(
ALL( dim_CALENDAR[DATE] ) ,
dim_CALENDAR[DATE] = MAX( dim_CALENDAR[DATE] )
)
VAR lv_MAX_YEAR_DAY =
CALCULATE(
VALUES( dim_CALENDAR[YEAR_DAY] ) ,
ALL( dim_CALENDAR ) ,
lt_MAX_DATE
)
RETURN
lv_MAX_YEAR_DAY
在我看来,对于最大日期的两个行,我应该获得
10
,但事实并非如此。
我的问题是:为什么dim_calendar [年]
上下文即使我已经使用了all()
函数?
感谢您的帮助。
I have defined the following table :
The following measure does not work as expected :
VAR lt_MAX_DATE =
FILTER(
ALL( dim_CALENDAR[DATE] ) ,
dim_CALENDAR[DATE] = MAX( dim_CALENDAR[DATE] )
)
VAR lv_MAX_YEAR_DAY =
CALCULATE(
VALUES( dim_CALENDAR[YEAR_DAY] ) ,
ALL( dim_CALENDAR ) ,
lt_MAX_DATE
)
RETURN
lv_MAX_YEAR_DAY
In my mind, I should get 10
for both rows of the Max Date ALL
column, but this is not the case.
My question is : why does a dim_CALENDAR[YEAR]
context apply even though I have used the ALL()
function?
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想要
dax
测量来返回maxyear
maxyear 的最大无论
年
目前在过滤器上下文中都可以看到,您都可以在许多方面实现它。其中两个如下。If you want the
DAX
measure to return the maxYear_day
ofmaxYear
by ignoring no matter whatyear
is currently visible in the filter context, you can achieve it in many ways. Two of them are as below.该表达式
与此表达式相同
,表达式的结果是所选年份的最后日期。您会得到一行过滤。
第二个表达式通过DAX优先级过滤表
,第一个工作所有(dim_calendar),然后应用过滤器-lt_max_date,
因此,您可以在矩阵行中获得DIM_CALENDAR表,只需在一年的最后一天过滤,具有值的单个值(DIM_CALENDAR [YEAR_DAY])。
您可以通过-lt_max_date
normaly越过所有(dim_calendar),您将使用lv_max_year_day语法遇到错误。计算返回标量值,而值()函数即使使用1个单元格也返回表。
This expression
is the same as
So, the result of the expression is the last date of the selected (in Row) year. You get a Row filtering.
The second expression filters the table by
According to DAX priorities, first works ALL(dim_CALENDAR) , then you apply filter - lt_MAX_DATE
So, you get the dim_CALENDAR table, simply filtered by the last day of the year in a matrix row where you get a single value with the VALUES( dim_CALENDAR[YEAR_DAY] ).
You overite ALL( dim_CALENDAR ) by the - lt_MAX_DATE
Normaly, you will get an error with lv_MAX_YEAR_DAY syntax. Calculate returns scalar value, while VALUES() function returns a table even with 1 cell.
正如@mik所说,您正在限制上下文
As @Mik says, you are restricting the context with