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

Expression nested too deep issue

Hi everyone.

I have a gallery that I'd like to filter by multiple columns (in their different combinations), thus I have several input controls. 

 

The Items property of the gallery looks like this:

 

Sort(
     If(Not(IsBlank(Emp.Text)) && Not(IsBlank(Con.Text)) && IsBlank(Dep.Text) && _selectedCount=2 && wm_1_filter =1,
    Filter('[dbo].[welcome_meetings_view]','Start Date'>=sel_start.SelectedDate && 'Start Date'<=sel_end.SelectedDate && Emp.Text in Employee && Con.Text in country && wm_date_1<>Blank()),

    If(
    IsBlank(Emp.Text) && IsBlank(Con.Text) && IsBlank(Dep.Text) && _selectedCount<1 && wm_1_filter =0,
    '[dbo].[welcome_meetings_view]',

    If(Not(IsBlank(Emp.Text)) && IsBlank(Con.Text) && IsBlank(Dep.Text) && _selectedCount<1 && wm_1_filter =0,
    Search('[dbo].[welcome_meetings_view]', Emp.Text, "Employee"),

...............some more IFs....................
)))))))),
    'Start Date',SortOrder.Ascending)

 

At some point I started getting an error: Expression nested too deep. An expression in your formula is nested more than 50 levels.

Is there a chance to avoid this error or to filter the gallery another way? Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@Margaryta 

Hard to tell without the complete formula.

In general, you should have 1 table returning function in your formula.  Use the criteria of the Filter to base your logic.  Lot's of If's in an Items formula will lead to pain.

 

Ex.

Sort(
    Filter('[dbo].[welcome_meetings_view]',
        (IsBlank(Emp.Text) || Emp.Text in Employee) &&
        (IsBlank(Con.Text) || Con.Text in country) &&
        (wm_date_1 = If(wm_1_filter=1, Blank(), "somethingElse")) &&
         etc...
    ),
    'Start Date', Ascending
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

1 REPLY 1
Super User III
Super User III

@Margaryta 

Hard to tell without the complete formula.

In general, you should have 1 table returning function in your formula.  Use the criteria of the Filter to base your logic.  Lot's of If's in an Items formula will lead to pain.

 

Ex.

Sort(
    Filter('[dbo].[welcome_meetings_view]',
        (IsBlank(Emp.Text) || Emp.Text in Employee) &&
        (IsBlank(Con.Text) || Con.Text in country) &&
        (wm_date_1 = If(wm_1_filter=1, Blank(), "somethingElse")) &&
         etc...
    ),
    'Start Date', Ascending
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (72,900)