Help! How can I create a view of matching records?

Hi all, I have an app which is a bit like a User Directory where users create a profile adding information about themselves (name, location, email, role, interests). Iโ€™d like to set up a view where the user can see other users with the same interests. All of the data is captured in a main table โ€˜Dataโ€™, however the โ€˜interestsโ€™ are selectable from a list in another table called โ€˜Interestsโ€™. Iโ€™m stuck on how to create this view. Iโ€™ve tried creating a slice using โ€˜FILTER(โ€œDataโ€,([Interests] = [_THISROW].[Interests]))โ€™ but I get the error โ€˜The expression is valid but its result type โ€˜Listโ€™ is not one of the expected types: Yes/Noโ€™. Any ideas?

Solved Solved
1 38 1,139
1 ACCEPTED SOLUTION

Could you please try an expression something like below in the slice filter

AND(COUNT( INTERSECT( [Interests], SPLIT(SELECT(Data[Interests],[Email] = USEREMAIL()), โ€œ,โ€)))>0 , [Email]<> USEREMAIL())

Have not tested it.

Minor edits in expression done.

View solution in original post

38 REPLIES 38

Please try slice filter expression as

IN([Date Tableโ€™s Key Column], FILTER(โ€œDataโ€,([Interests] = [_THISROW].[Interests])))

Hi @Suvrutt_Gurjar, Iโ€™ve just tried this but it only returns a โ€˜Yโ€™ for my record and not for any of the other records even though they have the same interests. Do you know if it searches within a string or is it looking for exact matches?

Is FILTER(โ€œDataโ€,([Interests] = [_THISROW].[Interests])) returning multiple key values?

You could test it in a VC in the same table.

It only returns my row, because only my row has a matching key (email address)

Got it. Sorry that I missed your latest update post and hence responding a day later. Just in case you are still looking for a solution, please try creating a slice expression something like below

[Interests]=LOOKUP(USEREMAIL(), โ€œDataโ€, โ€œEmail Column Nameโ€, โ€œInterestsโ€)

Thanks for this suggestion @Suvrutt_Gurjar, however I keep getting the error message;
โ€˜Cannot compare List with EnumList in ([Interests] = ANY(SELECT(Data[Interests],([Email] = USEREMAIL()))))โ€™

Any ideas?

What is the column type

EnumList - because it is referencing another table for itโ€™s values. Basically the user creates a profile and selects interests from a list. This list is held in another table hence EnumList.

Also since you are creating user based filters, please thoroughly understand the concepts of security filters and slice filters.

Please refer the section โ€œCan slices be used instead of a security filter?โ€ in the article below

The EnumList table is also called โ€˜Interestsโ€™.

Thanks. What if a user 1 has interests { A, B, C }, user 2 { D, B, C } user 3 { D, G }

Then what user 1, user 2 and user 3 should see in their respective slices?

I have a view called โ€˜Directoryโ€™ where the user should see all other people with matching interests to theirs. This is where the [Interests] slice would be.
In your example;
user 1 should only see user 2 in their Directory view
user 2 should see users 1 and 3 in their Directory view
user 3 should only see user 2 in their Directory view

Hope thatโ€™s clearer now.

Thanks

Can user 1 see himself also along with user 2

Can user 2 see himself also along with users 1 and 3

Can user 3 see himself also along with user 2

Ideally the user would not see themselves in the Directory view, this view will be used to connect with other members (send email, sms etc)
There is another view called โ€˜My Profileโ€™ where the user can see and update their own details.

Could you please try an expression something like below in the slice filter

AND(COUNT( INTERSECT( [Interests], SPLIT(SELECT(Data[Interests],[Email] = USEREMAIL()), โ€œ,โ€)))>0 , [Email]<> USEREMAIL())

Have not tested it.

Minor edits in expression done.

โ€œINTERSECT does not accept a list of list.โ€

Do you think it could be getting confused because I have columns with the same name in different tables?
I have my main table called โ€˜Dataโ€™ with a column called [Interests]
โ€˜Dataโ€™ references another table 'โ€˜Interestsโ€™ (a simple list) that also has a column called [Interests]

Can you share the screenprint of the expression entered in the slice filter formula and the error displayed?

It perfectly works for me.

SPLIT() is used to convert list of lists into a normalized list.

Hope your [Email] column name is [Email] only and [Interests] is an Enumlist column in โ€œDataโ€ table.

Yes @Suvrutt_Gurjar both of those are correct and yet I still get that error?!??

Please try changing Base type of Enumlist column [Interest] to Text and test

@Suvrutt_Gurjar you bloody legend!!! That seems to have done the trick

Thank you so much for all your help! Iโ€™ve been pulling my hair out over this. Now to test it with other usersโ€ฆ

Good to know it works. Please thank senior community guide @Steve as well. He asked to post the screenshot of the column setting where the final issue was hiding.

Can you just explain why that was the issue? So I know for future use. I have another table โ€˜LCRNโ€™ which is used in a similar manner although is Type Enum, should I be changing the base type of that column to text as well?

Yes, base type is applicable for Enum also.

The final issue was Enumlist column is list of some type of items. If it is a list of numbers , the base type of column needs to be Number. In your case base type was text, since [Interests] are list of texts. So a list can be of dates, numbers, texts and so on. Accordingly base type of Enumlist column needs to be selected. The earlier incorrect base type setting was โ€œEnumlistโ€, so it was creating list of lists and hence the error.

My request will be to go through following articles. AppSheet has rich set of well explained articles with examples. Please search by search words such as โ€œenumโ€, โ€œCOUNT()โ€, โ€œReferenceโ€ and you will get a list of relevant articles.

https://www.appsheet.com/Support

The following post has many references useful for an AppSheet app building

Hi @Suvrutt_Gurjar, if I now wanted to sort this list where would I add the SORT expression? Iโ€™ve tried adding it at the start and stating True as I want the list in descending order but I just canโ€™t get it to work. It says Sort has invalid inputs.

Thanks @Steve, I have tried this but it doesnโ€™t seem to like it hence my post. Iโ€™m trying to sort the following expression;

AND(
[Hide Profile] = โ€œNoโ€,
AND(COUNT(INTERSECT([Professional Interests], SPLIT(SELECT(Data[Professional Interests],[Email] = USEREMAIL()), โ€œ,โ€)))>0 , [Email]<> USEREMAIL()))

Basically Iโ€™d like the list sorted by number of matches (high to low). Iโ€™ve tried adding in Sort both before and after the second And statement but in both instances I get the message โ€˜Sort has invalid inputsโ€™.
Any ideas where Iโ€™m going wrong?

Oh, this is in a view. The order rows are displayed within a view is controlled by the view configuration, not by the slieโ€™s row filter condition.

The issue Iโ€™ve got is that the View doesnโ€™t allow me to sort by Expression (unless Iโ€™m missing something?) I can only sort by Columns. Any way around this?

There is no way to sort a view by expression.

Okay thanks. Possible future feature?

Please post a screenshot of the configuration screen of the Interests column, down to and including the entire Type Details section.

Thanks for this suggestion @Steve! @Suvrutt_Gurjar seems to have identified the issue and has provided a solution

My base table called โ€˜Dataโ€™

Configuration of the [Interests] column within โ€˜Dataโ€™.

Top Labels in this Space