Merging two Enumlist (Ref) and remove duplicates

Hi All,

I am trying to merge 2 lists and remove its duplicates. I tried the following:

UNIQUE(
	[Teaching_Tips_1]+	
	LOOKUP(
		MAXROW(
			"Class_Observations"
		,
			"Modified On"
		,
			[_THISROW].[Student] = [Student]
		)
	,
		"Class_Observations"
	,
		"Key"
	,
		"Add_Objective_1_Teaching_Tips"
	)
)

and received this error:
Arithmetic expression '([Teaching_Tips_1]+ANY(SELECT(Class_Observations[Add_Objective_1_Teaching_Tips],([Key] = ANY(SELECT(Class_Observations[Key],AND(([Key].[Student] = [Student]), ([Modified On] = MAX(SELECT(Class_Observations[Modified On],([Key].[Student] = [Student])))))))))))' has inputs of an invalid type 'Unknown'

So i tried this:

UNIQUE(
	[Teaching_Tips_1]+	
	List(LOOKUP(
		MAXROW(
			"Class_Observations"
		,
			"Modified On"
		,
			[_THISROW].[Student] = [Student]
		)
	,
		"Class_Observations"
	,
		"Key"
	,
		"Add_Objective_1_Teaching_Tips"
	))
)

No error but the duplicates arenโ€™t stripped away.

Note that this code is used in an action:
2X_b_b9dc5741011ad04db7789454e7da40159b12f039.png

Any help is appreciated. Thank you.

Alex

0 23 1,313
23 REPLIES 23

You need to use lists with the addition (+)โ€ฆ meaning LIST()+LIST().

Hi Aleksi,

I did try that and I still end up with duplicates.

UNIQUE(
	List([Teaching_Tips_1])+	
	List(LOOKUP(
		MAXROW(
			"Class_Observations"
		,
			"Modified On"
		,
			[_THISROW].[Student] = [Student]
		)
	,
		"Class_Observations"
	,
		"Key"
	,
		"Add_Objective_1_Teaching_Tips"
	))
)

2X_b_b7a9f2ed29a21bd679955992c020d6aeca64f158.png

-LIST("") at the end. UNIQUE sometimes seems to fail in these circumstances.

Thx Dave. Doesnโ€™t seem to work either in both case below.

UNIQUE(
	LIST([Teaching_Tips_1])+	
	LIST(LOOKUP(
		MAXROW(
			"Class_Observations"
		,
			"Modified On"
		,
			[_THISROW].[Student] = [Student]
		)
	,
		"Class_Observations"
	,
		"Key"
	,
		"Add_Objective_1_Teaching_Tips"
	))-LIST(" ")
)

UNIQUE(
	LIST([Teaching_Tips_1])+	
	LIST(LOOKUP(
		MAXROW(
			"Class_Observations"
		,
			"Modified On"
		,
			[_THISROW].[Student] = [Student]
		)
	,
		"Class_Observations"
	,
		"Key"
	,
		"Add_Objective_1_Teaching_Tips"
	))
)-LIST(" ")

I donโ€™t think it matters but both lists contains keys of the table Teaching Tips that are generated with UNIQUEID().

No space in between the quotes. Just double quotes right next to each other.

Same. In both cases. Which case you wanted me to try?

โ€“ LIST() usually works for me. Iโ€™ve not tried the UNIQUE() function yet.

@Brandt_Litton @Bahbus
Is that what you were thinking about?
UNIQUE(LIST("a, b, c, d, e")+LIST("d, e")-LIST())

The current test data is similar but it keeps returning LIST(โ€œa, b, c, d, e, d, eโ€)

Yes. But, like I said, Iโ€™ve only done that same thing without the UNIQUE() part of the expression. So for me itโ€™s usually LIST(โ€ฆ)+LIST(โ€ฆ)+LIST(โ€ฆ)-LIST() to get rid of duplicates.

this sounds terrible but maybe I can do LIST(A)+LIST(B)-INTERSECT(LIST(A), LIST(B))

or can I wrap the LIST(A) and LIST(B) in a select and use the argument to remove the duplicate?

Bahbus
New Member

Does work:
LIST("a", "b", "c", "d", "e")+LIST("d", "e", "f")-LIST("") = {a, b, c, d, e, f}

Doesnโ€™t work for me. Maybe the issue comes from this mismatch type.


โ€™
I have this error when I use INTERSECT(). I donโ€™t get why since they are both pointing toward 2 fields that are EnumList and Ref of the same table.

Wait. Is [Teaching_Tips_1] an EnumList? Thatโ€™s the reason itโ€™s not working. LIST([EnumList Column]) Iโ€™m pretty sure takes the content of the EnumList {โ€œtest1โ€, โ€œtest2โ€} (2 items) and converts it into a new list of {โ€œtest1, test2โ€} (1 item). Then itโ€™s {โ€œtest1, test2โ€} + {โ€œtest2โ€} = {โ€œtest1, test2โ€ , โ€œtest2โ€} (2 items). Thatโ€™s why UNIQUE() and the -LIST("") arenโ€™t working. As far as the expression is concerned, theyโ€™re different.

So try these two options:

UNIQUE(
	[Teaching_Tips_1]+	
	LIST(LOOKUP(
		MAXROW(
			"Class_Observations"
		,
			"Modified On"
		,
			[_THISROW].[Student] = [Student]
		)
	,
		"Class_Observations"
	,
		"Key"
	,
		"Add_Objective_1_Teaching_Tips"
	))
)

If that doesnโ€™t work, try:

UNIQUE(
	SPLIT([Teaching_Tips_1], ",")+	
	LIST(LOOKUP(
		MAXROW(
			"Class_Observations"
		,
			"Modified On"
		,
			[_THISROW].[Student] = [Student]
		)
	,
		"Class_Observations"
	,
		"Key"
	,
		"Add_Objective_1_Teaching_Tips"
	))
)

@Bahbus Thanks so much, I added the SPLIT for both columns and it works great

Just a question, why an EnumList of Ref isnโ€™t a regular LIST?

Mostly because its a mishmash of two seperate column types. But this problem would occur even if the column was of the List type (I think). Either way, the list is โ€œstoredโ€ as a string of text separated by comma (or a different delimiter if you define it). It would be equivalent to LIST(โ€œAโ€, โ€œBโ€, LIST(โ€œAโ€, โ€œBโ€)), but the editor can recognize that as a no-no.

@Bahbus I think I am having the same issue with enumlist of Ref again.

  • On table A, I have a field [Scope Card] that is an enumlist Ref of table Gyms
  • On table B, I have a field [Gym] that is a Ref of a the table Gyms
  • The key of table Gyms is a UNIQUEID() String

I am trying to use the current filter on a Slice of table B:

IN(
[Gym]
,
LOOKUP(CONTEXT(โ€œDeviceโ€), โ€œUser_Profilesโ€, โ€œDeviceโ€, โ€œCard Scopeโ€)
)

It always return false even with the correct data. So I tried:

IN(
[Gym]
,
SPLIT(LOOKUP(CONTEXT(โ€œDeviceโ€), โ€œUser_Profilesโ€, โ€œDeviceโ€, โ€œCard Scopeโ€), โ€œ,โ€)
)

Still doesnโ€™t work.

I did notice the filter working when I change the order of the values in the field Card Scope.

Any idea? Thx!

Try:

Try:

AND(
    TRUE, 
    IN(
        [_THISROW].[Gym],
        SPLIT(
            LOOKUP(
                CONTEXT(โ€œDeviceโ€), โ€œUser_Profilesโ€, โ€œDeviceโ€, โ€œCard Scopeโ€
            ), โ€œ,โ€
        )
    )
)

Thanks. I copied just a part of the filter. There are already other conditions.

I donโ€™t think the issue come from the context(device). I do have the same one for my test.

Is there a way to know exactly the list that gets return from the lookup? Some sort of debug print ability.

Using the test button on test button on that expression should show you.

Doesnโ€™t work either. Thanks though.

Well, Context(โ€œDeviceโ€) based stuff can kind of be difficult to debug. Because, the browsers UUID changes fairly easily, and when youโ€™re playing around in the editor, youโ€™re on the browser. But I believe, Iโ€™ve also seen reports in general of issues using IN() as the only condition of a slice. Donโ€™t know if that ever got fixed.

Top Labels in this Space