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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.