cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
diannottismh
Helper I
Helper I

Variable within a Variable

I have a Gallery that is accessed from several screens and I want it to update based on the information passed.  I set the Gallery Item as a variable "Cases".  I have four screens that navigate to this screen with the following variable onselect:Navigate(ClientCaseScreen,Transition.None,{Cases:SortByColumns(Filter('[dbo].[CaseTable]',ClientID=Client.ClientID), "IncidentDate", If(SortDescending2, Ascending,Descending))}) 

 

I get "The Function if has some invalid arugments" for the "If(SortDescending2, Ascending,Descending)"

 

I had it working for two of the screens but when I added a third screen it errored on all of them.

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

If the variable 'SortDescending2' is defined as local to a screen (using the UpdateContext function) then it can only be accessed from that screen. You can try changing it to a global variable: whenever you use the UpdateContext to set it, you change to use the Set function, which will define that variable in a way that it can be used in any screen.

 

Another alternative is to navigate passing only the client id for which you want to filter:

Navigate(ClientCaseScreen, Transition.None, {selectedClientID:Client.ClientID})

And use the filter in the gallery within that screen:

SortByColumns(
    Filter('[dbo].[CaseTable]', ClientID = selectedClientID),
    "IncidentDate",
    If(SortDescending2, Ascending, Descending))

View solution in original post

1 REPLY 1
CarlosFigueira
Power Apps
Power Apps

If the variable 'SortDescending2' is defined as local to a screen (using the UpdateContext function) then it can only be accessed from that screen. You can try changing it to a global variable: whenever you use the UpdateContext to set it, you change to use the Set function, which will define that variable in a way that it can be used in any screen.

 

Another alternative is to navigate passing only the client id for which you want to filter:

Navigate(ClientCaseScreen, Transition.None, {selectedClientID:Client.ClientID})

And use the filter in the gallery within that screen:

SortByColumns(
    Filter('[dbo].[CaseTable]', ClientID = selectedClientID),
    "IncidentDate",
    If(SortDescending2, Ascending, Descending))

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (3,446)