cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
zaxxon12345
Frequent Visitor

Filters and nested if statements on SharePoint lists

So this probably simple but it's driving me crazy. 

 

First, by default,  when a checkbox called "CheckOldEvents" is not checked I want my gallery that is linked to an SP List called "CISCoverageCal" to filter only to list items that are >= to today based on a date field called StartTIme.

Next, I want use a series of IF Statements that will further filter the list based on 2 Drop Downs. 

 

This seems like a nested IF Statement but how do I first reduce the list and then allow for the second set of IF Statements (created using the great Shane Young's tutorial video) to run against the previously filtered dataset?
Here's my code: 

 

If(CheckOldEvents.Value = false, Filter(CISCoverageCal, StartTIme >=Today()),
CISCoverageCal,
If(
//This is for All and all
drpRegion.Selected.Value = "All" && drpPrograms.Selected.Value = "All", CISCoverageCal,
//All Regions and selected Programs
drpRegion.Selected.Value = "All" && drpPrograms.Selected.Value <> "All",
Filter(CISCoverageCal, Program.Value = drpPrograms.Selected.Value ),
//Selected Regions and All Programs
drpRegion.Selected.Value <> "All" && drpPrograms.Selected.Value = "All",
Filter(CISCoverageCal, Region.Value = drpRegion.Selected.Value ),
//This is for selected Program and Region
drpRegion.Selected.Value <> "All" && drpPrograms.Selected.Value <> "All",
Filter(CISCoverageCal, Region.Value = drpRegion.Selected.Value && Program.Value= drpPrograms.Selected.Value )
),)

 

Any help would be greatly appreciated. 

1 ACCEPTED SOLUTION

Accepted Solutions
CNT
Community Champion
Community Champion

@zaxxon12345 Glad it works!

 

Please remember to give a 👍 and accept the solution as it will help others in the future.

View solution in original post

10 REPLIES 10
CNT
Community Champion
Community Champion

@zaxxon12345 try this

Filter(CISCoverageCal,

If((CheckOldEvents.Value, true, = false, StartTIme >=Today()) & &

(drpRegion.Selected.Value = "All", true, Region.Value = drpRegion.Selected.Value) & &

(drpPrograms.Selected.Value = "All", true, Program.Value= drpPrograms.Selected.Value )
)) 

zaxxon12345
Frequent Visitor

Thanks for the reply! Sorry, not sure I completely follow. But your idea did jog my brain a bit. Initially, I wanted to reduce the whole data set first to only show dates from Today forward (if the CheckOldEvents box is True) and then run my drop down filters off that data set, which I can't seem to do with 2 nested IF Statements. However, it does seem possible now to just add the 3rd permutation >= Today (CheckOldEvents box is True) to each individual IF test and resulting Filter function. 

Let me know if I'm missing something here, which I probably am. 🙂 

Thanks! 

CNT
Community Champion
Community Champion

@zaxxon12345 the formula I sent does what you wanted. Give it a try and let me know if it works. 

CNT
Community Champion
Community Champion

@zaxxon12345 Did you get a chance to try it out 🤔?

 

zaxxon12345
Frequent Visitor

Thanks for checking back. I can't get it to work. But it's probably just me and my weak formula skills. 😉 

CNT
Community Champion
Community Champion

@zaxxon12345 Could you please share a screen shot.

zaxxon12345
Frequent Visitor

Screen Shot 2021-06-03 at 7.48.19 AM.png

CNT
Community Champion
Community Champion

@zaxxon12345 Please try this,

 

Filter(CISCoverageCal,
If((CheckOldEvents.Value=true, true, StartTIme >=Today()) & &
(drpRegion.Selected.Value = "All", true, Region.Value = drpRegion.Selected.Value) & &
(drpPrograms.Selected.Value = "All", true, Program.Value= drpPrograms.Selected.Value )
)) 

 

zaxxon12345
Frequent Visitor

Thanks again for the help. I ended up reconfiguring the formula and controls a bit. I had the checkbox update a collection that fed the dropdown rather than using a boolean. In the end this is what I got to work: 

Filter(
CISCoverageCal,
IsEmpty(drpRegion.Selected.Value) || IsBlank(drpRegion.Selected.Value) || Region.Value = drpRegion.Selected.Value,
IsEmpty(drpPrograms.Selected.Value) || IsBlank(drpPrograms.Selected.Value) || Program.Value = drpPrograms.Selected.Value,
IsEmpty(drpCoverFilter.Selected.Value) || IsBlank(drpCoverFilter.Selected.Value) || Status.Value = drpCoverFilter.Selected.Value
)

 

Thanks again! 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (930)