Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Add a condition to a Search/Switch/If formula

Posted on 21 Nov 2024 10:59:26 by 8
Hi, 

I have a formula which is used to filter a table. On the page there are a dropdown (which is used to filter by date), a checkbox (which is used to filter on status "Aangemeld") and a textinput to manual search on name or organization. I want to add an extra checkbox to filter on blank status, but I am a bit lost on where to add this to the formula.
It is quite a messy bit already to be honest.

This is how it’s build up at the moment:



Search(
    Switch(
        Drop_Filter.Selected.Value;
        "Alles";
        If(
            Checkbox_Filter_Aanmelden.Checked;
            Filter(
                bVisitorBezoekers;
                Status.Value = "Aangemeld"
            );
            bVisitorBezoekers
        );
        "Geschiedenis";
        If(
            Checkbox_Filter_Aanmelden.Checked;
            Filter(
                bVisitorBezoekers;
                Aankomst < Today() && Status.Value = "Aangemeld"
            );
            Filter(
                bVisitorBezoekers;
                Aankomst < Today()
            )
        );
        "Toekomst";
        If(
            Checkbox_Filter_Aanmelden.Checked;
            Filter(
                bVisitorBezoekers;
                Aankomst > varTomorrow && Status.Value = "Aangemeld"
            );
            Filter(
                bVisitorBezoekers;
                Aankomst > varTomorrow
            )
        );
        "Vandaag";
        If(
            Checkbox_Filter_Aanmelden.Checked;
            Filter(
                bVisitorBezoekers;
                Aankomst >= varToday && Aankomst < varTomorrow && Status.Value = "Aangemeld"
            );
            Filter(
                bVisitorBezoekers;
                Aankomst >= varToday && Aankomst < varTomorrow
            )
        );
        If(
            Checkbox_Filter_Aanmelden.Checked;
            Filter(
                bVisitorBezoekers;
                Status.Value = "Aangemeld"
            );
            bVisitorBezoekers
        )
    );
    SearchInput_1.Value;
    Titel;
    Organisatie
)
  • CT-30090658-0 Profile Picture
    CT-30090658-0 8 on 21 Nov 2024 at 11:53:50
    Add a condition to a Search/Switch/If formula
     Hi mmbr1606
     
    Thank you for your reply! It seems to work, but i'll have to test it the comming day. 
    Will take a look in the || operator  and how it exactly works. 
     
    have a good day! 
  • Verified answer
    mmbr1606 Profile Picture
    mmbr1606 9,803 on 21 Nov 2024 at 11:11:52
    Add a condition to a Search/Switch/If formula
    hey
     
     
    can u try this:
    Search(
        Switch(
            Drop_Filter.Selected.Value;
            "Alles";
            Filter(
                bVisitorBezoekers,
                If(
                    Checkbox_Filter_Aanmelden.Checked && Checkbox_Filter_BlankStatus.Checked,
                    Status.Value = "Aangemeld" || IsBlank(Status.Value),
                    Checkbox_Filter_Aanmelden.Checked,
                    Status.Value = "Aangemeld",
                    Checkbox_Filter_BlankStatus.Checked,
                    IsBlank(Status.Value),
                    true
                )
            ),
            "Geschiedenis";
            Filter(
                bVisitorBezoekers,
                Aankomst < Today(),
                If(
                    Checkbox_Filter_Aanmelden.Checked && Checkbox_Filter_BlankStatus.Checked,
                    Status.Value = "Aangemeld" || IsBlank(Status.Value),
                    Checkbox_Filter_Aanmelden.Checked,
                    Status.Value = "Aangemeld",
                    Checkbox_Filter_BlankStatus.Checked,
                    IsBlank(Status.Value),
                    true
                )
            ),
            "Toekomst";
            Filter(
                bVisitorBezoekers,
                Aankomst > varTomorrow,
                If(
                    Checkbox_Filter_Aanmelden.Checked && Checkbox_Filter_BlankStatus.Checked,
                    Status.Value = "Aangemeld" || IsBlank(Status.Value),
                    Checkbox_Filter_Aanmelden.Checked,
                    Status.Value = "Aangemeld",
                    Checkbox_Filter_BlankStatus.Checked,
                    IsBlank(Status.Value),
                    true
                )
            ),
            "Vandaag";
            Filter(
                bVisitorBezoekers,
                Aankomst >= varToday && Aankomst < varTomorrow,
                If(
                    Checkbox_Filter_Aanmelden.Checked && Checkbox_Filter_BlankStatus.Checked,
                    Status.Value = "Aangemeld" || IsBlank(Status.Value),
                    Checkbox_Filter_Aanmelden.Checked,
                    Status.Value = "Aangemeld",
                    Checkbox_Filter_BlankStatus.Checked,
                    IsBlank(Status.Value),
                    true
                )
            ),
            If(
                Checkbox_Filter_Aanmelden.Checked;
                Filter(
                    bVisitorBezoekers;
                    Status.Value = "Aangemeld"
                );
                bVisitorBezoekers
            )
        ),
        SearchInput_1.Value,
        "Titel", "Organisatie"
    )
    
    if it helped mark as verified
     
     
    cheers

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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,051

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,793

Leaderboard