Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

View all the Fabric Data Days sessions on demand. View schedule

Reply
dkc
Helper I
Helper I

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.

CustomerCount_SelectedSalesReps =
VAR SelectedCustTable =
    IF(
        ISFILTERED('Hierarchy level Slicer'[HIERARCHY_LEVEL]),
        VALUES('Hierarchy level Slicer'[HIERARCHY_LEVEL]),
        ALL('Hierarchy level Slicer'[HIERARCHY_LEVEL])
    )

VAR ThisCustomer = MAX('FACTS_C4C Promos'[Hierarchy Level])

RETURN
CALCULATE(
    COUNTROWS('DIM_Customer Master'),
    FILTER(
        'DIM_Customer Master',
        'DIM_Customer Master'[CUSTOMER_MASTER_DATA_HIERARCHY_LEVEL] = ThisCustomer
            &&
   
        CONTAINSROW(SelectedCustTable, 'DIM_Customer Master'[CUSTOMER_MASTER_DATA_HIERARCHY_LEVEL])
    )
)
1 ACCEPTED SOLUTION
danextian
Super User
Super User

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]
                    )
            )
        )
    )

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
dkc
Helper I
Helper I

thank you, now it was working and I understood the logic

danextian
Super User
Super User

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]
                    )
            )
        )
    )

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

Could you share some data, explain the question and share the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors