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 / Gallery and filter wit...
Power Apps
Answered

Gallery and filter with IF

(0) ShareShare
ReportReport
Posted on by 58

Hi Gurus 


I have

1)3 buttons . "ABBtn","PQBtn","XYBtn",
2) A search option - WellNameSearch_2
3) Gallery 


When button is selected am defaulting variable varFormTab with each button value . Set(varFormTab, "ABBtn") accordingly

Question: I would like to fill the gallery with values as per each button and the filters corresponding to each button which is selected . I am getting error "If have invalid arguments " 

Requesting help. Gallery items Code below.


If(

varFormTab = "ABBtn",
SortByColumns(Filter('TEST - Schedule',StartsWith(WELL_NAME,WellNameSearch_2.Text),
NAME IN ( 'A AREA', 'B AREA', 'C AREA')
),"START_DATE",Ascending),


varFormTab = "PQBtn",
SortByColumns(Filter('TEST - Schedule',StartsWith(WELL_NAME,WellNameSearch_2.Text),
NAME IN ( 'P AREA', 'Q AREA', 'R AREA' )
),"START_DATE",Ascending),

varFormTab = "XYBtn", SortByColumns(Filter('TEST - Schedule',StartsWith(WELL_NAME,WellNameSearch_2.Text)),"START_DATE",Ascending)

)

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @avi2017 

    Please consider changing your Formula to the following:

    SortByColumns(
     Filter('TEST - Schedule',
     StartsWith(WELL_NAME, WellNameSearch_2.Text),
     (varFormTab = "ABBtn" && (NAME in 'A AREA' & 'B AREA' & 'C AREA') ||
     (varFormTab = "PQBtn" && (NAME in 'P AREA' & 'Q AREA' & 'R AREA')
     ),
     "START_DATE"
    )

    I am assuming that things like 'A AREA' are text columns in your datasource, but I am not clear on your logic with comparing to NAME - which I also assume is a column in your datasource.

    So, if the above does not work as expected, please provide more detail on those items.

     

    I hope this is helpful for you.

  • avi2017 Profile Picture
    58 on at

    @RandyHayes  Thanks for the reply 

    Tried the code below but now it is giving delegation warning and no values returning

     

     

    SortByColumns
    (
    Filter('TEST - Schedule',
    StartsWith(WELL_NAME, WellNameSearch_2.Text),
    (varFormTab = "ABBtn" && ( NAME in "A AREA" & "B AREA" & "C AREA" ) ||
    (varFormTab = "PQBtn" && ( NAME in "P AREA" & "Q AREA" & "R AREA" ))
    ),
    "START_DATE",Ascending
    )

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @avi2017 

    Please tell me more about what A AREA and B AREA, etc, are.  This is now inconsistent with your first formula and what I provided.

  • avi2017 Profile Picture
    58 on at

    Hi @RandyHayes 

     

    App screen shot attached 

     

    NAME is column in Sharepoint 

     

    Am trying to filter values in the gallery as per the button selected by user - "ABBtn","PQBtn","XYBtn",

    WellSearch is another search option which is common for all butttons

    App Screen.jpg
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @avi2017 

    Very good, then you will need the following formula:

    SortByColumns(
     Filter('TEST - Schedule',
     StartsWith(WELL_NAME, WellNameSearch_2.Text),
     (varFormTab = "ABBtn" && (NAME = "A AREA" || NAME = "B AREA" || NAME = "C AREA")) ||
     (varFormTab = "PQBtn" && (NAME = "P AREA" || NAME = "Q AREA" || NAME = "R AREA"))
     ),
     "START_DATE"
    )

     

    However, in regard to your picture, if NAME is what you have displayed in that Gallery, then the above formula will never match.   I don't see anything in the picture that indicates anything "A AREA", "B AREA", etc.

  • avi2017 Profile Picture
    58 on at

    @RandyHayes 

    Thanks a lot . How will I make all items to display when "AllBtn" is clicked ?

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @avi2017 

    SortByColumns(
     Filter('TEST - Schedule',
     StartsWith(WELL_NAME, WellNameSearch_2.Text),
     (varFormTab = "AllBtn" ||
     (varFormTab = "ABBtn" && (NAME = "A AREA" || NAME = "B AREA" || NAME = "C AREA")) ||
     (varFormTab = "PQBtn" && (NAME = "P AREA" || NAME = "Q AREA" || NAME = "R AREA"))
     )
     ),
     "START_DATE"
    )

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 396 Most Valuable Professional

#2
11manish Profile Picture

11manish 134 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 101 Super User 2026 Season 2

Last 30 days Overall leaderboard