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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
deepu299
Advocate V
Advocate V

Using IN Operator with List of Values

Hi, 

 

I am trying to write a DAX function using IN operator. The problem is, I have the list of values which goes between {} are in another table. So I am trying to bring in those values to use in the IN operator. I see the contenateX function is bringing all the values like a list, but they don't work when used with IN. Can someone please help?

 

VAR _List = CONCATENATEX(FILTER('Static Table', 'Static Table'[Type]= "DIVISION"),CONCATENATE( CONCATENATE("""",'Static Table'[Value]), """"), ",")    /* this is giving me values like "Div1", "Div2", "Div3" */

RETURN
SWITCH(TRUE(),
'Employee'[Division] IN {_List}, "Y", "N")

4 REPLIES 4
amitchandak
Super User
Super User

@amitchandak - Thanks for your response. I am aware on how to do with the values hardcoding, in my case the values are in another table which keeps changing, so wanted to read through a query and pass to the IN clause. It helps us to control the values from database instead of editing the model everytime. Hope it clarifies on what I am looking for. 

I tried it between two unrelated tables. And able to filter values based on compare date on sales.

All sedlected = CALCULATE(sum(Sales[Sales Amount]),Sales[Sales Date] in ALLSELECTED('Compare Date'[Compare Date]))

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

@amitchandak  I have tried that before posting here. The problem is my table has lot of other values, so I need to apply FILTER before selecting all the values. I am not able to use FILTER function along with ALL. I don't have anything to compare in the target table, I just need to get list of values to pass to the IN condition. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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