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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
cb123456
New Member

IN operator with variable from concatenatex

Hi all,

 

I want to use the IN operator in a measure to calculate a sum. If I enter the needed criterias directly it works and provides the correct results, e.g.

 

IN {"ABC";"DEF";"GHI";"JKL";"MNO"}
 
ABC-MNO are part of another table and stored in multiple lines each linked to a contract number. Therefore I created a measure using CONCATENATEX to get the needed values. 
 
[CONC]=Calculate(CONCATENATEX(Table1;""""&Table1[KEY1]&"""";";");Table1[Field]="M007")
 
The result of this measure is e.g. "ABC";"DEF";"GHI";"JKL";"MNO" but could also be "ABC";"GHI";"MNO"
 
Using the result of the CONCATENATEX as a variable and put it into the Measure gives back no error message but also no values.
 
sales =
 
var AC =[conc]

RETURN
 
CALCULATE(SUM(Table2[sales]);FILTER(Table2;Table2[AC_key] IN {AC}))
 
 
If I hardcode the variable with "ABC" it works but using hard coded "ABC";"DEF" etc. it does also not work.
 
Any ideas? Where is my mistake? Or is there maybe a better solution?
 
Best regards and thank you!
2 REPLIES 2
amitchandak
Super User
Super User

@cb123456 , Now sure Why are you doing like that

 

you can try

 

CALCULATE(SUM(Table2[sales]);FILTER(Table2;Table2[AC_key] IN value(Table1[Key]) ))

 

or

 

CALCULATE(SUM(Table2[sales]);FILTER(Table2;Table2[AC_key] IN summarize(filter(Table1[Field]="M007"),Table1[Key])))

 

or refer

https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Thanks for your response and your support! Attached an example of my data structure. Table 1 contains information for different contracts. For each contract I need to calculate the sales that are stored in table 2 based on the entries made under the different FIELDCOMB. So for Num 1 I need the sales from table 2 where O004=AA and C001 = 123456 and O002 =ABC etc. And for Num 2 I need the sales where O002=ABC and C001=234567 and also C001 = 123456 and M007 is not AER, AEU, AEV, AEW, AEZ (Each entry can either be "inclusive" I or "exclusive" E). So I have multiple lines per contract that I need to evaluate based on columns in theTable 2.example.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.