Re: Double IF condition with multiple rows

1747 0
cancel
Showing results for
Did you mean:
4 - Data Explorer

Hello all!

I have a question. I would like to create a formula with 2 conditions. IF “Item” in row 1 = “item” in row 2 AND “P” in row 1 is equal to “P” in row 2 then “it’s ok” otherwise “it’s not”

Do you think it’s possible?

Thanks for your help!

5 Replies 5
18 - Pluto

Airtable’s data storage is closer to a database than a spreadsheet. Because of that, each row is a record, and database records have no inherent knowledge of each other, so it’s impossible to directly reference any other record to get values, make comparisons, etc.

Could you describe in greater detail what you’re trying to achieve? You didn’t mention where you want this “It’s OK”/“It’s not” output to go, but also knowing the bigger picture would help us to help you more effectively.

That aside, there’s one possible way to pull this off that I can think of. I’ve quickly recreated what I think might be your setup, using an [Items] table to contain the linked items from this main table, which I’ll call [Main] for now. In my setup, I made the {P} field a number instead of single line text, which will make the comparison easier.

Over in the [Items] table, I added a rollup field to pull in the contents of the {P} field based on those links from the [Main] table. If you just use an aggregation formula of “values” for the rollup field, this will show all the values separated by commas.

However, if we change the aggregation formula to this, we get the result you want:

IF(MAX(values) = MIN(values), "It's OK", "It's not")

values represents the array of collected values from the [Main] table for that linked item, and the MAX() and MIN() functions return the largest and smallest items in that array, respectively. In short, if the largest and smallest values are the same, then both values are identical.

We can now use a lookup field back in the [Main] table to pull in this result:

If both numbers match, the other result appears:

NOTE: This technique doesn’t really work that well if there are more than two links for any given item, but the use case you outlined only contains two items, which is why I’m suggesting this as a possible solution.

4 - Data Explorer

Wow impressive! in reality the picture is a little bit wider.

Here are all the parameters.
I wouldlike to know if “it’s ok” or “it’s not” with the parameter we talk about previously but there is one more parameter. The starting date and the ending date.

IF “Item” in row 1 = “item” in row 2 AND Item in row 1 has at least a day in common with “item” in row 2 then identify it as “conflict”. Once identify as a “conflict” IF “P” in row 1 is equal to “P” in row 2 then “it’s ok” otherwise “it’s not”

It’s a little bit more complicated :slightly_smiling_face:

I don’t know if it’s possible or not…

18 - Pluto

In Airtable terms, it’s actually a lot more complicated, and unfortunately it’s not possible, at least not by modifying the setup I created. The hiccup is that you’re not just comparing dates, but overlapping date ranges, and that’s not something that Airtable can currently do via formulas. For this, you’d need to resort to some type of scripting solution, either a manually-run script in the Scripting block, or one driven by Airtable’s relatively-new automation system. If you’d like help setting this up, just ask. There are several of us here who can take care of that, but it would most likely need to be taken on as a client project, as this is a very unique use case that would require custom code.

4 - Data Explorer

I have another thing I woulklike to go which need script. Do you know someone who can take care of that?
Thanks again!

18 - Pluto

I can create a custom scripting solution for you. Send me a direct message and we can discuss the options.