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

Refer to a Filter result in a formula

Hello,

I am currently trying to make an 'Inventory App' for my company.
I use a SP List. I implemented an option to book a certain Item, but now I am looking for a way to kind of put the Item back into storage.
When booking an item I let the App create a new Entry with the same name and the desired amount, which gets substracted from the original one.
The 'back into storage' function so far looks like this:

Patch(
Inventar;
First(
Filter(
Inventar;
Title = InventarGalerie.Selected.Title && ID < InventarGalerie.Selected.ID
)
);
{Anzahl: + InventarGalerie.Selected.Anzahl}
)

For reference: Anzahl = Amount, Inventar = SP List, InventarGalerie = Galery that displays the list

The first part seems to work fine, but I have no idea how i can refer to the filter results in my formula.
I think i need something like {Anzahl: FilterResult + InventarGalerie.Selected.Anzahl} .


Any help will be apreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Refer to a Filter result in a formula

Hi @dkey ,

Could you please share a bit more about your scenario?

Do you want to reference the Filtered result from the Filter formula within your Patch function?

 

If you want to reference the Filtered result from the Filter formula within your Patch function, I have made a test on my side, please consider modify your formula as below:

Patch(
     Inventar;
     First(
            Filter(
                   Inventar;
                   Title = InventarGalerie.Selected.Title && ID < InventarGalerie.Selected.ID
                  )
     );
     {           /* <-- Modify your formula below */
Anzahl: First(Filter(Inventar; Title = InventarGalerie.Selected.Title && ID < InventarGalerie.Selected.ID)).Anzahl + InventarGalerie.Selected.Anzahl
} )

Please take a try with above solution, check if the issue is solved.

 

More details about Filter function in PowerApps, please check the following aeticle:

Filter function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Refer to a Filter result in a formula

Hi @dkey 

Unless I misunderstand you, you'd like to refer to the record that you've just updated with Patch.

If that's the case, it's worth noting that the return value from Patch contains the updated record.

For example if you use the following formula, you can use LastUpdatedRecord to refer to the record that you updated.

 

Set(LastUpdatedRecord;
Patch(Inventar; First( Filter( Inventar; Title = InventarGalerie.Selected.Title && ID < InventarGalerie.Selected.ID ) ); {Anzahl: + InventarGalerie.Selected.Anzahl} )
)

 

 

 

Community Support
Community Support

Re: Refer to a Filter result in a formula

Hi @dkey ,

Could you please share a bit more about your scenario?

Do you want to reference the Filtered result from the Filter formula within your Patch function?

 

If you want to reference the Filtered result from the Filter formula within your Patch function, I have made a test on my side, please consider modify your formula as below:

Patch(
     Inventar;
     First(
            Filter(
                   Inventar;
                   Title = InventarGalerie.Selected.Title && ID < InventarGalerie.Selected.ID
                  )
     );
     {           /* <-- Modify your formula below */
Anzahl: First(Filter(Inventar; Title = InventarGalerie.Selected.Title && ID < InventarGalerie.Selected.ID)).Anzahl + InventarGalerie.Selected.Anzahl
} )

Please take a try with above solution, check if the issue is solved.

 

More details about Filter function in PowerApps, please check the following aeticle:

Filter function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

dkey
Regular Visitor

Re: Refer to a Filter result in a formula

@v-xida-msftThank you for the quick response, the solution you provided works!

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,084)