简体   繁体   中英

Count last X cells from another sheet containing Y, as percentage

I have an overly complex Excel file that I have been using to track my progress learning golf. Specifically, I have a sheet that shows my average distance for the last X shots per club. The X is a drop down below the data table.

Sheet showing Shot Distribution with Quick Stats

Data Table with dropdown

Currently, only the 'Avg. Yds' column changes based on the previous number selected from the drop down list. However, I would also like for the 'Left', 'Right', and 'Center' columns to adjust so that I can see if my accuracy is improving in relation to my distance. Currently, the Distribution columns are static and show the percentage of all shots inputted.

Recap: I am trying to work out a formula that calculates percentage of previous X shots that were Left of my target.

My formula for the Avg. Yds of my driver is

=AVERAGE(OFFSET(Table!B2,0,COUNT(Table!B2:VO2)-1,,-G27))

and seems to work fine.

My formula for the Distribution for Left of my driver is

=COUNTIF(Table!B3:VO3,"Left")/COUNTA(Table!B3:VO3)

but shows all inputted values from the 'Table' sheet and not just the values from the last X shots.

As requested, here is a sample of the source data from the Table sheet: Source Data

Two approaches are as shown below. In both cases, the formulas are for the same driver row as per your "My formula for the Distribution..." above

Using a COUNTIF approach the formula would be:

=COUNTIF(OFFSET(Table!B3,0,COUNTA(Table!B3:VO3)-1,,-G27),"Left")/G27

Alternately, you could use an array formula:

{=SUM(IF(OFFSET(Table!B3,0,COUNTA(Table!B3:VO3)-1,,-G27)="Left",1))/G27}

Both do the same thing, so use whichever you're most comfortable with.
And I suspect after seeing these, you'll realise the solution was staring at you the whole time 😊

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM