Thank you, this was exactly what I wanted to do but couldn't find a good solution. Yours was the simplest one and it worked like a charm.
However, it only works when creating a new item. When I editing an existing item, the error is displayed when it shouldn't (at least in my case). Here is what I did to resolve this, although I'm sure there are simpler ways:
First, I created two additional text labels:
LabelID with text property: ThisItem.ID
LookupID with text property: LookUp('Post-Mortem Tracker', Ticket = DataCardValue1.Text, ID)
Finally, I edited the UniqueValueError formula as follows:
If(
And(
UniqueTicketValue.Text = "true",
Not(LookupID.Text = LabelID.Text)
),
"Ticket number already exists. Please edit the existing entry instead.",
""
)