How to get only unique results in a report based on a particular column

I have a bot that generates an email based on an email template.  In the template I have the following expression:

Name

I-CAR ID

Role

<<Start:orderby(Select([Related GC Requirements][_RowNumber], [Activated]=No, True),[Name])>>

<<[Name]>>

<<[I-CAR ID]>>

<<[PDP Role]>>

I want to make it so that I only get unique [Name] results.  I currently have the select statement set to return only distinct rows, but in this data there are often numerous distinct rows with the same [Name].  Basically I want a particular [Name] to only appear once in the email, whereas right now I get the same [Name] over and over if there are multiple rows for it.  Any help?  Thanks!

Solved Solved
0 10 1,444
1 ACCEPTED SOLUTION

I appreciate everyone's contributions... they sparked my imagination.  However, I think between not being familiar with my data and perhaps misunderstanding my objective a bit, everyone was (unintentionally) trying to make this more complex than it needed to be.  I found a simple solution:

I created a slice, similar to @Suvrutt_Gurjar's suggestion.  It filtered the data as follows:

and(
[Activated]=No,
isnotblank([Name])
)

The "isnotblank" on the Name field just scrubs out some anomalies in the data.  One thing I didn't bother mentioning is that this data is provided to us from an external source, so unless I want to do a bunch of scripts and/or spreadsheet formula gyrations (which I personally find inelegant and prone to breakage) in Google Sheets prior to Appsheet "ingesting" the data, I had to do a little scrubbing.  I prefer to clean my data within Appsheet when possible.

Anyhow, this slice resulted in only the rows without an Activated status.  Yay.  I then created a virtual column ("Name and ID") that was a concatenation of the Name (main thing I was going for) and their ID, which is helpful as well.

I need to execute this bot at the row level based on a table of locations so each manager gets a list of the people he needs to active, so I then created another virtual column on the locations table (which was the source of the dereference in the original template) as follows:

Select(Not Activated[Name and ID], ([_THISROW] = [Linked Location]),true)

Notice this allows me to procure a list of only unique data based on the virtual column [Name and ID] I created above.  Since I'm not creating a dereference here, I can get away without using the key field, which skirts around the issue of not being able to procure unique rows in the template.  As an aside, I find it unfortunate that in Appsheet functions such as UNIQUE() when wrapping a SELECT() take into account the key field, which should be unique, so therefore they don't do anything in that case.  Took me awhile to figure that out.

So now my template just outputs the above virtual column for each location.  I would say "easy peasey" but it really wasn't.  Took me a few hours to figure all this out and unfortunately that kind of time just doesn't exist for me during the work week.  Just thought I'd share my solution in case others could benefit from it.  Thank you again for your help, without your ideas I wouldn't have come up with it.

View solution in original post

10 REPLIES 10