函数计算已在真/假表达式中使用,该表达式用作不允许的表过滤器表达式 [英] a function calculate has been used in a true/false expression that is used as a table filter expression which is not allowed

查看:40
本文介绍了函数计算已在真/假表达式中使用,该表达式用作不允许的表过滤器表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 ssas 表格模型中检查当前月份和当前年份的值,但由于类型不匹配,我无法执行此操作.为此,我创建了一个度量,其中我使用了这个 dax 查询

I have a to check the current month and current year value for a measure in ssas tabular model but due to type mismatch i am not able to do this. For this, i have created a measure in which i am using this dax query

:CurrMonthYear:=CONCATENATE(CONCATENATE("""",concatenate(year(now()),CONCATENATE(0,month(now())))),"""")       output: "201704"

...计算当前年份和当前月份.但是当我以这样的方式给出这个值时:

...to calculate currentyear and currentmonth. But when i give this value in a measure like this:

SumOfRevisedForecast:=CALCULATE(SUM(DimRevisedForecast[RevisedForecast]),DimRevisedForecast[Approved] <>"N"  && DimRevisedForecast[Approved] <>blank(),'DimRevisedForecast'[CalendarYearMonth] =CurrMonthYear)

...这不起作用.尽管如此,用201704"代替 CurrMonthYear 是有效的.

...this doesnt work. Though, giving "201704" in place of CurrMonthYear works.

有人可以帮我吗?

提前致谢

推荐答案

问题不在于 CurrMonthYear 度量,而在于您的第二个公式 - CALCULATE 函数不接受度量作为标准,只接受值.这就是为什么当您明确输入201704"时它有效但在使用该度量时失败的原因.

The problem is not with CurrMonthYear measure, it's with your second formula - CALCULATE function does not accept measures as criteria, only values. That's why it works when you put "201704" explicitly but fails when you use the measure.

一个常见的解决方案是将条件包装到 FILTER 函数中,例如:

A common solution is to wrap the criteria into FILTER function, something like:

CALCULATE(SUM(DimRevisedForecast[RevisedForecast]), 
          FILTER ('DimRevisedForecast',  
                  'DimRevisedForecast'[CalendarYearMonth] = [CurrMonthYear])

这个问题的一个很好的解释在这里:FILTER() – 何时、为什么、&如何使用它

A great explanation of this issue is here: FILTER() – When, Why, & How to Use It

这篇关于函数计算已在真/假表达式中使用,该表达式用作不允许的表过滤器表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆