web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Prevent duplicate entr...
Power Apps
Suggested Answer

Prevent duplicate entries in a List

(0) ShareShare
ReportReport
Posted on by 59
 
I use a button to update my List, and it works.
 
Before updating, I want to check if the combination of "Place"+"Month"+"Year" exists in the List, and if it does, do not add an entry.
 
I've tried many things, but I always get error.
 
This is my code :
 
// This is one thing I tried for the duplicate check, but I get errors for the comparisons, "Incompatible types for comparison.".
Set(
    existingRecord,
    LookUp(
        'Fréquentation mensuelle',
        Lieu = Lieu.SelectedText &&
        Mois = MonthDropdown.SelectedText &&
        Année = Value(YearInput.Text)
    )
);
 
If(
    IsBlank(existingRecord),
    Patch(
        'Fréquentation mensuelle',
        Defaults('Fréquentation mensuelle'),
        {
            Lieu: Lieu.SelectedText,
            Mois: MonthDropdown.SelectedText,
            Année: Value(YearInput.Text),
            Visiteurs: Value(PeopleInput.Text)
        }
    );
 
    Reset(PeopleInput);
    Notify("Succès", NotificationType.Success),
    // If duplicate exists, show error notification
    Notify("Ce lieu pour ce mois et cette année existe déjà.", NotificationType.Error)
);
Categories:
  • Suggested answer
    trogne Profile Picture
    59 on at
    This works! :
    ClearCollect(
        AllRecords,
        'Fréquentation mensuelle'
    );
     
    ClearCollect(
        FilteredRecords,
        ForAll(
            AllRecords,
            {
                LieuText: Lieu.Value,
                MoisText: Mois.Value,
                AnneeText: Text(Année)
            }
        )
    );
     
    Set(
        duplicateRecord,
        LookUp(
            FilteredRecords,
            LieuText = Lieu.Selected.Value &&
            MoisText = MonthDropdown.Selected.Value &&
            AnneeText = Text(Value(YearInput.Text))
        )
    );
     
    Set(duplicateFound, !IsBlank(duplicateRecord));
     
    If(
        duplicateFound,
        Notify("Ce lieu-mois-année existe déjà.", NotificationType.Error),
        Patch(
            'Fréquentation mensuelle',
            Defaults('Fréquentation mensuelle'),
            {
                Lieu: { Value: Lieu.Selected.Value },
                Mois: { Value: MonthDropdown.Selected.Value },
                Année: Value(YearInput.Text),
                Visiteurs: Value(PeopleInput.Text)
            }
        );
     
        Reset(PeopleInput);
        Notify("Succès", NotificationType.Success)
    );


     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 360 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard