Reply
Highlighted
Frequent Visitor
Posts: 3
Registered: ‎09-24-2018
Accepted Solution

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

Accepted Solutions
Frequent Visitor
Posts: 3
Registered: ‎09-24-2018

Re: Using the "in" operator inside Measure

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


All Replies
Member
Posts: 66
Registered: ‎05-28-2018

Re: Using the "in" operator inside Measure

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))

 

Senior Member
Posts: 385
Registered: ‎04-14-2018

Re: Using the "in" operator inside Measure

@StefanDK

 

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"))
Frequent Visitor
Posts: 3
Registered: ‎09-24-2018

Re: Using the "in" operator inside Measure

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