Unique line items in a table

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have table with 50 city names with some duplicate city names.  I only want one to show a city once.  how do I do this?
https://drive.google.com/file/d/0B409lhd9sYDcUVdzQjN5alQ1RlE/view
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You could create an aggregate model or use javascript to abandonRow duplicate city names.
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb

I did this.  What else do I need to do?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Add all the fields that you want to display as aggregations, and then create a table on your model. You have to drag and drop the fields from the model field list into the model.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I looks like your table is still bound to the basic model.  You need to change the Model that drives the table to the aggregate one you built.  

But here is where things get tricky.   Every field you want to show in the table will have to be in the grouping section.  And there is no way to include formula fields in grouping statements (This is a core limitation to Salesforce SOQL).   

Actually Matt's answer is a little misleading.   If you put your fields in the "Aggregation" section of your model - you won't be able to show field values,  just do calculations like COUNT.   Helpful in some cases, but not in yours. 

If this does not work the solutions are going to be much harder - either Apex code to prevent the duplicate entries,  or Javascript code to analyze the model presented to the client and abandon the duplicate rows.  Both of these are outside the bounds of what we can provide in basic support.   
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You could use agg model as a condition to a basic model. In the agg model, set your conditions as desired and group by City and Id.

In your basic model, set the condition on Id to be "in" the agg model id values.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Don't think this will work.  If 2 rows in basic model match the row in the aggregate model - you still have duplicate rows in your table. 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Great solution there from Pat.

Rob, I'm pretty sure I've used MAX 'aggregations' for text fields with success. But groupings does seem to make more sense.
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb
Hello Pat,

Thanks, that seems like it should work.  I believe I have followed your instructions but not yet working.  Here is how i have it set up:

https://drive.google.com/file/d/0B409lhd9sYDcWS1DaEhRc281ZFE/view?pli=1

Bill
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Should work. Do you have skype? pat.vachon.77
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb
yes. I will c
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb
Thanks Pat that worked great.