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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Using the "in" operator inside Measure

Hello,

 

I've already used the "in" operator succesfully inside calculated tables. But when I try to use the same syntax inside a measure, than it does not seem to work:

 

 
NewMeasure = 

var vSelection=calculatetable(selectcolumns('table1', "Selection",[items]))
return
calculate(max(table2[Score]),filter(all(table2),table2[item] in vSelection))




 

Does anyone have an idea how to solve this? By the way, table2 is a calculated table.
 
Kind regards,
 
Stefan
1 ACCEPTED SOLUTION
Anonymous
Not applicable

My apologies, the code I have given does work .... but after some nights sleep, I finally noticed now that I had overlooked that a linkage between two tables is affecting my results. So nothing wrong with the code itself 

Thank you all,

 

Stefan

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

My apologies, the code I have given does work .... but after some nights sleep, I finally noticed now that I had overlooked that a linkage between two tables is affecting my results. So nothing wrong with the code itself 

Thank you all,

 

Stefan

themistoklis
Community Champion
Community Champion

@Anonymous

 

You can use CONTAINS on a calculate column and then add this column to a measure:

New Column = IF (CONTAINS([Content],"SHOWS"),"SHOWS",IF ([Content] IN {"DRY","WATER"},"DRY","HC"))
petrovnikitamai
Resolver V
Resolver V

i'm not sure,

in this case vSelection is table

filter "in" works with list of values only

try this

 

NewMeasure = 
var vSelection=values(table1[items])
return
calculate(max(table2[Score]),filter(all(table2),table2[item] in vSelection))

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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