Forum Academy Marketplace Showcase Pricing Features

Unique Elements for Date Range

I’ve been trying organize events in a repeating group according to a date range. In order to do this I’ve created a repeating group with the events nested in another repeating group with the date range. The problem arises when I use the operator :unique elements to eliminate duplicates but the duplicates are still shown. I’ve checked the date ranges to confirm that they are all the same and the same problem arises. Anybody else having problems with date ranges and unique elements?

Can you possibly use the ‘:group by’ field? Select the data field as “grouping” then do your Search for date and choose :grouped by at the end. Create a new group and choose ‘date’ with either an exact, day, or month match.

I had the same issue when creating invoices. I had several visits for one day and I only wanted to show the same date once. I kept getting duplicates as well.

When you display the date, choose ‘current cells grouping date’

Hey @efrainw, this is actually a really good question. Unfortunately, not all operations that we might desire to do with date ranges are supported in Bubble. For example, you can’t sort by a date range (but you could sort by a date range’s start or date range’s end I suppose).

Similarly, we can’t simply ask if one date range “equals” another. What we would mean by that is, if I have two date ranges x<- ranged with ->y and a<- ranged with ->b, if x equals a and y equals b, then we might say that the ranges are equal. (Although I guess with parentheses turned on, we could in fact evaluate that now in Bubble, but we would need to express it in this way.)

Internally to Bubble, a date range is a two-element JavaScript array of dates like [startDate, endDate].

A funny thing about arrays: They are objects and all objects are unique. So if I make var a = [date1, date2] and var b = [date1, date2] and I ask if a equals b (a == b) the answer will be false. That is, we’d need to evaluate the equivalence of those arrays in the same way as I described before (check if the first elements are equal and the second elements are equal).

So, this is the long explanation of why we can’t apply :unique elements to a list of date range objects: Every date range is, in fact, unique. (This holds for numeric ranges as well.)

This omission on Bubble’s part could be considered a bug and you might want to file a bug report about it (really more of a request-for-enhancement) but don’t hold your breath on that being “fixed”.

I thought I had a clever :filter list expression idea that could remove duplicates if you have parens turned on:

(In my case, my list of date ranges is called Parallels's B's Split: Date Ranges List).

But I think what this expression will do if filter out any date range that is found elsewhere in the list, so it’s not quite what we want… Anyway, a plugin or List Item Expression could do this and I should have just written the code for that and provided it here.

Could also be done with Process List action in List Shifter. (An explanation of this is rather long.)

1 Like

BTW, I have a plugin almost done for this (it’ll be in my Floppy plugin collection) that I’m publishing later tonight. Just needs a little more testing and a little bug fix.

1 Like

@efrainw - my plugin for deduplicating and/or sorting lists of date ranges is now available in Floppy. Floppy is a commercial plugin collection, and offers many other features besides the Floppy Date Range Processor plugin that I just included in it. It’s a bargain at $6/month to test/subscribe (prorated as Bubble plugins are), or $12 for a permanent purchase in your app.

Description here:

That’s the description for now, but I’ll do a video about its usage soon. If you’re familiar with element plugins in general and my plugins in particular, you’ll immediately understand how to use Floppy Date Range Processor. Demo page here with editor link to inspect:

1 Like

Hey there @Keith, thanks for the explanation on why data ranges work in a different way when using :unique elements. I still haven’t taken the time to rummage through your solution. By the way, have you tried making the plugin for this “problem”.

Nice, will take a look at it.

This topic was automatically closed after 14 days. New replies are no longer allowed.