Forum Discussion

dkc's avatar
dkc
Helper I
9 months ago
Solved

The CONTAINSROW function expects a table expression for argument '', but a string or numeric express

Hi, I am not sure how to correct this formula, I always get the error note The CONTAINSROW function expects a table expression for argument '', but a string or numeric expression was used. Customer...
  • danextian's avatar
    9 months ago

    Hi dkc 

    You cannot use a condition to return a table or table expression. While SelectedCustTable doesn't return an error using this in another expression will cause an error.  Try this:

    VAR SelectedCustTable01 =
        VALUES ( 'Hierarchy level Slicer'[HIERARCHY_LEVEL] )
    VAR SelectedCustTable02 =
        ALL ( 'Hierarchy level Slicer'[HIERARCHY_LEVEL] )
    VAR ThisCustomer =
        MAX ( 'FACTS_C4C Promos'[Hierarchy Level] )
    RETURN
        IF (
            ISFILTERED ( 'Hierarchy level Slicer'[HIERARCHY_LEVEL] ),
            CALCULATE (
                COUNTROWS ( 'DIM_Customer Master' ),
                FILTER (
                    'DIM_Customer Master',
                    'DIM_Customer Master'[CUSTOMER_MASTER_DATA_HIERARCHY_LEVEL] = ThisCustomer
                        && CONTAINSROW (
                            SelectedCustTable01,
                            'DIM_Customer Master'[CUSTOMER_MASTER_DATA_HIERARCHY_LEVEL]
                        )
                )
            ),
            CALCULATE (
                COUNTROWS ( 'DIM_Customer Master' ),
                FILTER (
                    'DIM_Customer Master',
                    'DIM_Customer Master'[CUSTOMER_MASTER_DATA_HIERARCHY_LEVEL] = ThisCustomer
                        && CONTAINSROW (
                            SelectedCustTable02,
                            'DIM_Customer Master'[CUSTOMER_MASTER_DATA_HIERARCHY_LEVEL]
                        )
                )
            )
        )