cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JustRestart
Level: Powered On

How to find row number of currently selected item?

Hi,

 

I'm trying to wrap my head around how I can find the sum of specific rows from a Selected Gallery Item, as I want to create a report screen that shows the total costs of products that a business has.

 

Below is the table I'm using.

 

Screen Shot 2018-11-22 at 8.31.14 pm.png

 

I want to find the sum of Cost1, Cost2 and Cost3 from a selected gallery, in this case Business 1, and output that number into a label. 

 

I've gotten basic output data with Sum(Business, Cost1+ Cost2) and it shows the total cost of the column, but would like just the specific row. 

 

I'm sure this is easy, but I'm new to powerapps and struggling to figure this out. 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft Employee

Re: How to find row number of currently selected item?

Here is how to run the test from my previous message:

1. Create a blank app

2. Add a Blacnk vertical Gallery control and a Label control to the screen.

3. Select the Gallery control and paste the following into gallerie's "Items" property:

[{a:1, b:10},{a:2, b:20},{a:3, b:30},{a:4, b:40}]

This basically assigns a "table" with 4 rows and 2 columns to your gallery.

4. Select the Label control and paste the following into the "Text" property:

Last(FirstN(Gallery1.AllItems, 2)).Value.a + Last(FirstN(Gallery1.AllItems, 2)).Value.b

This formula basically says: From all the galleries items (Gallery.AllItems), get the "a" and "b" values from the second row (Last(FirstN(... , 2)) and add them together.

View solution in original post

4 REPLIES 4
Microsoft Employee

Re: How to find row number of currently selected item?

The following test should help you calculate the sum values from 2 columns from the second row:

Gallery1.Items = [{a:1, b:10},{a:2, b:20},{a:3, b:30},{a:4, b:40}]

Label1.Text = Last(FirstN(Gallery1.AllItems, 2)).Value.a + Last(FirstN(Gallery1.AllItems, 2)).Value.b

The Label control should display "22" which is the sum of "a" and "b" column values from the second row.

Hope this helps.

 

JustRestart
Level: Powered On

Re: How to find row number of currently selected item?

Thanks for the reply, but dont really understand too much of the code written. Where do I insert the Gallery1.Items part? Is that for the 'Items' value for my gallery, as I have tried that and it wouldn't allow it. 

 

Is there any documentation on this topic that you can point me too? 

Thanks.

 

Microsoft Employee

Re: How to find row number of currently selected item?

Here is how to run the test from my previous message:

1. Create a blank app

2. Add a Blacnk vertical Gallery control and a Label control to the screen.

3. Select the Gallery control and paste the following into gallerie's "Items" property:

[{a:1, b:10},{a:2, b:20},{a:3, b:30},{a:4, b:40}]

This basically assigns a "table" with 4 rows and 2 columns to your gallery.

4. Select the Label control and paste the following into the "Text" property:

Last(FirstN(Gallery1.AllItems, 2)).Value.a + Last(FirstN(Gallery1.AllItems, 2)).Value.b

This formula basically says: From all the galleries items (Gallery.AllItems), get the "a" and "b" values from the second row (Last(FirstN(... , 2)) and add them together.

View solution in original post

JustRestart
Level: Powered On

Re: How to find row number of currently selected item?

Fantastic! 

Thanks for the help, it definitely clarifys things as I was wondering what the array was and how it should be put into powerapps.

 

Thanks dinusc!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,193)