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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
RyanHare92
Helper I
Helper I

Using list of values in IN function

Hi,

I have the following measure:

 

Status = 
VAR _Series_Month =
    LEFT(MAX(all_series[series]), SEARCH(" ", MAX(all_series[series])) - 1)

VAR _Key_Markets =
    SWITCH(
        _Series_Month,
        "March", 
            {"Country1"},
        "June", 
            {"Country2", "Country3", "Country4"},
        "November", 
            {"Country5", "Country6"},
        BLANK()
    )

VAR _Key_Market_Q =
    CALCULATE(
        MAX(key_Customer_Entries[Q%]),
        key_Customer_Entries[country] IN _Key_Markets,
        key_Customer_Entries[ses_name] = MAX(all_series[series])
    )

RETURN 
    _Key_Market_Q

 

 

However, I keep getting the following error:

The function expects a table expression for argument '', but a string or numeric expression was used.

How do I pass the values from _Key_Markets into _Key_Market_Q correctly?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @RyanHare92 ,

You can follow the steps to get it:

1. Create a dimension table as below

vyiruanmsft_0-1706176198939.png

2. Update the formula of your measure[Status] as below 

Status =
VAR _Series_Month =
    LEFT (
        MAX ( all_series[series] ),
        SEARCH ( " ", MAX ( all_series[series] ) ) - 1
    )
VAR _Key_Markets =
    CALCULATETABLE (
        VALUES ( 'Table'[Countries] ),
        FILTER ( 'Table', 'Table'[Month] = _Series_Month )
    )
VAR _Key_Market_Q =
    CALCULATE (
        MAX ( key_Customer_Entries[Q%] ),
        key_Customer_Entries[country] IN _Key_Markets,
        key_Customer_Entries[ses_name] = MAX ( all_series[series] )
    )
RETURN
    _Key_Market_Q

If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with special examples and screenshots. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @RyanHare92 ,

You can follow the steps to get it:

1. Create a dimension table as below

vyiruanmsft_0-1706176198939.png

2. Update the formula of your measure[Status] as below 

Status =
VAR _Series_Month =
    LEFT (
        MAX ( all_series[series] ),
        SEARCH ( " ", MAX ( all_series[series] ) ) - 1
    )
VAR _Key_Markets =
    CALCULATETABLE (
        VALUES ( 'Table'[Countries] ),
        FILTER ( 'Table', 'Table'[Month] = _Series_Month )
    )
VAR _Key_Market_Q =
    CALCULATE (
        MAX ( key_Customer_Entries[Q%] ),
        key_Customer_Entries[country] IN _Key_Markets,
        key_Customer_Entries[ses_name] = MAX ( all_series[series] )
    )
RETURN
    _Key_Market_Q

If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with special examples and screenshots. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

lbendlin
Super User
Super User

This is a dilemma.  The SWITCH statement cannot return objects, only simple data types. 

 

You need to refactor the query to pull the switch into the final step, or use SEARCH  instead with a string concatenation of your match terms.

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.