Exclude already used elements from the list

Hello everyone! An indirect continuation of this post. The question is the following. There are two tables. The first (Table 1) table has one column filled with serial numbers (one entry per row). The second table (Table 2) has a column in which serial numbers from the first table are written, separated by commas, using EnumList and IN. I canโ€™t figure out how to make it so that when adding serial numbers again, those numbers that have already been added are not offered.

I tried options with subtracting a list from a list, I also tried the NOT CONTAINS function, but it does not work. It turns out that in my "Table 2" each line with serial numbers is a small list of several values โ€‹โ€‹separated by commas. There are many such rows and they all need to be subtracted from the column in "Table 1".

Table 2

 

IMG_20220206_000154.jpg

Table 1

IMG_20220206_000215.jpg

โ€ƒ

Solved Solved
0 4 393
1 ACCEPTED SOLUTION

The problem you are likely facing is getting the complete list assigned Serial Numbers from the EnumList column.  When selecting that column from Table2 you are returned a List of LIsts.  It needs to be flattened to just a single list.

Try an expression like this (replace the table and column names for your use case):

SELECT(Table1[Serial Number], NOT(IN([Serial Number], Split(Text(Table2[Serial Numbers]), ","))))

Also, if you are allowing Editing of your Table 2 rows, you will probably need a slightly modified version that will still include the values from the current row.  That expression needs to be something like this:

SELECT(Table1[Serial Number], 
       OR(
          NOT(IN([Serial Number], Split(Text(Table2[Serial Numbers]), ","))),
          IN(Serial Number, [_THISROW].[Serial Numbers]
       )
)

NOTE:  These have not been tested.

 

 

 

View solution in original post

4 REPLIES 4

The problem you are likely facing is getting the complete list assigned Serial Numbers from the EnumList column.  When selecting that column from Table2 you are returned a List of LIsts.  It needs to be flattened to just a single list.

Try an expression like this (replace the table and column names for your use case):

SELECT(Table1[Serial Number], NOT(IN([Serial Number], Split(Text(Table2[Serial Numbers]), ","))))

Also, if you are allowing Editing of your Table 2 rows, you will probably need a slightly modified version that will still include the values from the current row.  That expression needs to be something like this:

SELECT(Table1[Serial Number], 
       OR(
          NOT(IN([Serial Number], Split(Text(Table2[Serial Numbers]), ","))),
          IN(Serial Number, [_THISROW].[Serial Numbers]
       )
)

NOTE:  These have not been tested.

 

 

 

Thanks for the advice! I'll check it out soon. By the way, I am now constantly confused by the SELECT function because of its possible performance impact.

Performance is typically not an issue if you follow best practices.  I wouldn't be concerned unless you have tens of thousands of rows or need to implement something extraordinarily complex.  If you do, come back here!! 

I tested the solution you suggested and it worked for me ๐Ÿ˜€

Thanks a lot for your help!

Top Labels in this Space