Intermittent error: DAX expression with SSAS on prem server

Intermittent error: DAX expression with SSAS on prem server

我目前正在更新 SASS 服务器版本 13.0 上本地托管的表格模型。表格模型是版本 1200。 我们在度量中创建了复杂的逻辑,允许我们定义计数规则或根据在断开连接的表中选择的参数进行过滤。 该模型是使用雪花“like”模式创建的:可以简化如下

Link 到图像:https://ibb.co/WfkmNPV

DAX Studio 或 PowerBI 返回的错误(间歇性地)如下:

MdxScript(Model) (5174, 18) Calculation error in measure 'Admission'[Number of Clients]: Function 'CONTAINS' does not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.

有时错误会自行解决,而无需我们进行任何操作或(有时)通过重新处理模型。 在某些情况下,我们所有的措施都会返回此错误。在其他情况下,它只是其中的一些。

'Admission'[客户数量]的DAX表达式如下:

Admission[Number of Clients] := 
VAR MinDate = MIN ( 'Date'[Full Date] )
VAR MaxDate = MAX ( 'Date'[Full Date] )
VAR AdmissionDate =
    FILTER (
        Admission,
        SWITCH (
            TRUE (),
            VALUES ( 'Counting Rules'[Counting Rule] ) = "Starts",
                Admission[Start Date] >= MinDate && Admission[Start Date] <= MaxDate,
            VALUES ( 'Counting Rules'[Counting Rule] ) = "Ends",
                Admission[End Date] >= MinDate && Admission[End Date] <= MaxDate,
            VALUES ( 'Counting Rules'[Counting Rule] ) = "Active",
                Admission[Start Date] <= MaxDate && Admission[End Date] >= MinDate,
            0
        )
    )
RETURN
IF (
    COUNTROWS ( VALUES ( 'Counting Rules'[Counting Rule] ) ) = 1,
    CALCULATE (
        DISTINCTCOUNT ( 'Admission'[ClientKey] ),
        FILTER (
            AdmissionDate,
            IF ( RELATED ( 'Clients'[Date Of Birth] ) <= MAX ( 'Date'[Full Date] )
                    && ( ISFILTERED ( 'Client Age'[Age Band] ) || ISFILTERED ( 'Client Age'[Age] ) ),
                IF ( COUNTROWS ( VALUES ( 'Age Counting Rule'[Age Counting Rule] ) ) = 1,
                    INTERSECT (
                        VALUES ( 'Clients Age'[Age] ),
                        SELECTCOLUMNS (
                            ADDCOLUMNS (
                                VALUES ( Admission[ClientKey] ),
                                "Age",
                                    ROUNDDOWN (
                                        DATEDIFF (
                                            CALCULATE ( MAX ( 'Clients'[Date Of Birth] ) ),
                                            VAR AdmissionDateFiltered =
                                                IF (
                                                    VALUES ( 'Age Counting Rule'[Age Counting Rule] ) = "Age Min",
                                                    CALCULATE ( MIN ( Admission[Start Date] ), AdmissionDate, EARLIER ( Admission[ClientKey] ) = Admission[ClientKey] ),
                                                    CALCULATE ( MAX ( Admission[End Date] ), AdmissionDate, EARLIER ( Admission[ClientKey] ) = Admission[ClientKey] )
                                                )
                                            RETURN
                                                IF ( VALUES ( 'Age Counting Rule'[Age Counting Rule] ) = "Age Min",
                                                    IF ( AdmissionDateFiltered < MIN ( 'Date'[Full Date] ) && NOT ISBLANK ( AdmissionDateFiltered ),
                                                        MIN ( 'Date'[Full Date] ),
                                                        AdmissionDateFiltered
                                                    ),
                                                    IF ( AdmissionDateFiltered > MAX ( 'Date'[Full Date] ) && NOT ISBLANK ( AdmissionDateFiltered ),
                                                        MAX ( 'Date'[Full Date] ),
                                                        AdmissionDateFiltered
                                                    )
                                                ),
                                            DAY
                                        ) / 365.25,
                                        0
                                    )
                            ),
                            "Age", [Age]
                        )
                    ),
                    BLANK ()
                ),
                TRUE ()
            ) //GOM Status
            && IF (
                ISFILTERED ( 'Guardianship Status'[Guardianship Type] ) || ISFILTERED ( 'Guardianship Status'[Guardianship Type Description] ) || ISFILTERED ( 'Guardianship Status'[Under Guardianship] ),
                CONTAINS (
                    VALUES ( 'Guardianship Status'[Guardianship Type] ),
                    'Guardianship Status'[Guardianship Type],
                    [Child Protection Order Active]
                ),
                TRUE ()
            )
        )
    ),
    BLANK ()
)

表达式的 GOM 部分中的措施 [儿童保护令有效] 正在返回一个字符串值。 我对逻辑做的修改是Age的计算方式。

你们中有人遇到过这个错误吗? 你会如何调试这样的东西?

感谢您花时间帮助我。

我已经解决了我的问题,方法是在 [儿童保护令有效] 周围添加一个条件来检查它是否 return 空白。 度量总是 returning 一个字符串(至少我假设考虑到代码)但出于某种奇怪的原因,引擎认为它可能 return 空白(另一个假设)。 空白值被视为整数,因此 return 是上述初始 DAX 表达式的错误。