SOLVED
Home

Formulaic calculation of table rows

%3CLINGO-SUB%20id%3D%22lingo-sub-1283266%22%20slang%3D%22en-US%22%3EFormulaic%20calculation%20of%20table%20rows%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1283266%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20automatically%20update%20a%20chart%20that%20only%20displays%20the%20last%2030%20entries%20in%20a%20large%20(%26gt%3B600%20rows)%20table.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can't%20find%20a%20formula%20like%20%22%3CEM%3E%3DNumRows(Table1)%3C%2FEM%3E%22%20to%20use%20in%20calculating%20the%20max%20number%20of%20rows%2C%20then%20with%20a%20formula%20(in%20the%20'choose%20data'%20dialog)%26nbsp%3Bset%20the%20chart%20range%20to%20'%3CEM%3E%3DNumRows(Table1)-30%3C%2FEM%3E%3A%3CEM%3ENumRows(Table1)%3C%2FEM%3E%2C%20for%20instance.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20such%20an%20animal%20exist%3F%20Can%20counting%20table%20rows%20be%20accomplished%20without%20resorting%20to%20VB%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20I%20select%20the%20chart's%20value%20line%2C%20the%20data%20it's%20based%20on%20is%20enclosed%2Fhighlighted%2C%20and%20I%20manually%20move%20the%20data%20targets%20down%20a%20row%20to%20only%20include%20the%20last%2030%20rows%3B%20be%20neat%20to%20not%20have%20to%20do%20that%20manually.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1283266%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ECharting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1283291%22%20slang%3D%22en-US%22%3ERe%3A%20Formulaic%20calculation%20of%20table%20rows%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1283291%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F610270%22%20target%3D%22_blank%22%3E%40akseeker%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20seem%20to%20referring%20some%20custom%20function%20%3CEM%3ENumRows.%20%3C%2FEM%3EThere%20is%20no%20built-in%20function.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20i%20understood%20you%20wish%20to%20get%20the%20last%2030%20day%20transaction%20from%20the%20range%2C%20Well%20I%20can%20suggest%20you%20try%20building%20using%20OFFSET%20function..%20If%20you%20still%20facing%20issue%20attach%20a%20sample%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards%2C%20Faraz%20Shaikh%20%7C%20MCT%2C%20MIE%2C%20MOS%20Master%2C%20Excel%20Expert%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%20class%3D%22lia-message-body%20lia-component-message-view-widget-body%20lia-component-body-signature-highlight-escalation%20lia-component-message-view-widget-body-signature-highlight-escalation%22%3E%3CDIV%20class%3D%22lia-message-body-content%22%3E%3CP%3E%3CEM%3E%3CFONT%20color%3D%22%23808080%22%3EIf%20you%20find%20the%20above%20solution%20resolved%20your%20query%20don't%20forget%20mark%20as%26nbsp%3B%3CSPAN%3EOfficial%20Answer%26nbsp%3Bto%20help%20the%20other%20members%20find%20it%20more%3C%2FSPAN%3E.%3C%2FFONT%3E%3C%2FEM%3E%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1286127%22%20slang%3D%22en-US%22%3ERe%3A%20Formulaic%20calculation%20of%20table%20rowse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1286127%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F156456%22%20target%3D%22_blank%22%3E%40Faraz%20Shaikh%3C%2FA%3E%26nbsp%3Byou%20are%20correct%2C%20I%20was%20looking%20for%20a%20function%20that%20would%20return%20the%20total%20number%20of%20rows%20in%20a%20table%20in%20order%20to%20use%20the%20offset%20function.%20Unless%20you%20know%20the%20total%20number%20of%20rows%20in%20the%20table%2C%20how%20would%20you%20apply%20the%20offset%20function%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20my%20question%20is%2C%20how%20does%20one%20(functionally)%20determine%20the%20number%20of%20rows%20in%20a%20table%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1286282%22%20slang%3D%22en-US%22%3ERe%3A%20Formulaic%20calculation%20of%20table%20rowse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1286282%22%20slang%3D%22en-US%22%3E%3CP%3EHI%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F610270%22%20target%3D%22_blank%22%3E%40akseeker%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20need%20to%20construct%20array%20formula%2C%20here%20is%20how%20it%20should%20work.%20If%20you%20are%20using%20office365%20with%20new%20dynamic%20arrays%20calculation%20engine%20you%20can%20paste%20the%20formula%20straight%20away%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DMAX(ROW(Table1%5BCount%20Row%5D)-1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20not%20paste%20the%20formula%20and%20press%20ctrl%20%2B%20shift%20%2B%20enter%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-04-06_23-26-01.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F182534i7B39EBB78BD5C74A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%222020-04-06_23-26-01.png%22%20alt%3D%222020-04-06_23-26-01.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards%2C%20Faraz%20Shaikh%20%7C%20MCT%2C%20MIE%2C%20MOS%20Master%2C%20Excel%20Expert%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%20class%3D%22lia-message-body%20lia-component-message-view-widget-body%20lia-component-body-signature-highlight-escalation%20lia-component-message-view-widget-body-signature-highlight-escalation%22%3E%3CDIV%20class%3D%22lia-message-body-content%22%3E%3CP%3E%3CEM%3E%3CFONT%20color%3D%22%23808080%22%3EIf%20you%20find%20the%20above%20solution%20resolved%20your%20query%20don't%20forget%20mark%20as%26nbsp%3B%3CSPAN%3EOfficial%20Answer%26nbsp%3Bto%20help%20the%20other%20members%20find%20it%20more%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FEM%3E%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1286755%22%20slang%3D%22en-US%22%3ERe%3A%20Formulaic%20calculation%20of%20table%20rowse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1286755%22%20slang%3D%22en-US%22%3E%3CP%3EGreat%20answer%20%40Faraz%2C%20that%20worked%20perfectly%2C%20thank%20you.%3CBR%20%2F%3E%3CBR%20%2F%3EPS%3A%20I%20looked%20in%20all%20the%20drop-down%20menus%20I%20could%20see%20on%20this%20page%2C%20but%20can't%20see%20an%20obvious%20way%20to%20set%20the%20question%20to%20'solved'.%20I%20set%20it%20to%20Best%20Response%2C%20but%20don't%20see%20how%20to%20set%20it%20to%20'Official%20Answer'.%20How%20is%20that%20accomplished%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1287202%22%20slang%3D%22en-US%22%3ERe%3A%20Formulaic%20calculation%20of%20table%20rows%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1287202%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F156456%22%20target%3D%22_blank%22%3E%40Faraz%20Shaikh%3C%2FA%3E%26nbsp%3B%2C%20now%20the%20next%20problem%20is%20using%20that%20info%20in%20the%20Chart%3AData%20dialog%3A%3C%2FP%3E%3CP%3E(attached%20a%20spreadsheet%20as%20example)%3C%2FP%3E%3CP%3EThe%20formulas%20currently%20read%26nbsp%3B%3CEM%3E%3DWidgets!%24I%2471%3A%24I%24101%3C%2FEM%3E%20in%20the%20Y-Value%20field%2C%20and%26nbsp%3B%3CEM%3E%3DWidgets!%24A%2471%3A%24A%24101%3C%2FEM%3E%20in%20the%20'Horizontal%20(Category)%20axis%20labels'%20field.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20named%20the%20results%20of%20the%20%22%7B%3DMAX(%E2%80%A6)-30%7D%22%20cell%20to%20%3CEM%3EChartStartRow%3C%2FEM%3E%20(H104)%2C%20and%20the%20result%20of%20the%20%7B%3DMAX(%E2%80%A6))%7D%20to%20%3CEM%3EChartEndRow%3C%2FEM%3E%20(H105).%20I%20concatenated%20those%20into%20a%20cell%2C%20with%20the%20calculated%20ranges%20listed%20out%20in%20text%20format%2C%20and%20named%20the%20cells%20%3CEM%3EXRange%3C%2FEM%3E%20(J104)%26nbsp%3Band%20%3CEM%3EYRange%3C%2FEM%3E%20(J105).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20do%20I%20get%20that%20calculation%20into%20the%20X%20and%20Y-Values%20fields%20in%20the%20chart%20data%20dialog%20box%3F%26nbsp%3BI%20tried%20several%20approaches%2C%20but%20they%20all%20resulted%20in%20errors.%20It%20doesn't%20appear%20formulas%20%5Be.g.%20INDIRECT()%5D%20are%20allowed%20in%20the%26nbsp%3B%3CSTRONG%3ESelect%20Data%20Source%3C%2FSTRONG%3E%20fields.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20wanted%20to%20avoid%20VB%E2%80%A6%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I'm trying to automatically update a chart that only displays the last 30 entries in a large (>600 rows) table.

 

I can't find a formula like "=NumRows(Table1)" to use in calculating the max number of rows, then with a formula (in the 'choose data' dialog) set the chart range to '=NumRows(Table1)-30:NumRows(Table1), for instance.

 

Does such an animal exist? Can counting table rows be accomplished without resorting to VB?

 

Now, I select the chart's value line, the data it's based on is enclosed/highlighted, and I manually move the data targets down a row to only include the last 30 rows; be neat to not have to do that manually.

 

Thanks!

5 Replies
Highlighted

Hi @akseeker,

 

You seem to referring some custom function NumRows. There is no built-in function.

 

What i understood you wish to get the last 30 day transaction from the range, Well I can suggest you try building using OFFSET function.. If you still facing issue attach a sample file.

 

Regards, Faraz Shaikh | MCT, MIE, MOS Master, Excel Expert

If you find the above solution resolved your query don't forget mark as Official Answer to help the other members find it more.

Highlighted

@Faraz Shaikh you are correct, I was looking for a function that would return the total number of rows in a table in order to use the offset function. Unless you know the total number of rows in the table, how would you apply the offset function?

 

So, my question is, how does one (functionally) determine the number of rows in a table?

 

Thanks

Highlighted
Solution

HI @akseeker 

 

You need to construct array formula, here is how it should work. If you are using office365 with new dynamic arrays calculation engine you can paste the formula straight away

 

=MAX(ROW(Table1[Count Row])-1)

 

If not paste the formula and press ctrl + shift + enter 

 

2020-04-06_23-26-01.png

 

Regards, Faraz Shaikh | MCT, MIE, MOS Master, Excel Expert

If you find the above solution resolved your query don't forget mark as Official Answer to help the other members find it more

Highlighted

Great answer @Faraz, that worked perfectly, thank you.

PS: I looked in all the drop-down menus I could see on this page, but can't see an obvious way to set the question to 'solved'. I set it to Best Response, but don't see how to set it to 'Official Answer'. How is that accomplished?

Highlighted

Thanks @Faraz Shaikh , now the next problem is using that info in the Chart:Data dialog:

(attached a spreadsheet as example)

The formulas currently read =Widgets!$I$71:$I$101 in the Y-Value field, and =Widgets!$A$71:$A$101 in the 'Horizontal (Category) axis labels' field.

 

I've named the results of the "{=MAX(…)-30}" cell to ChartStartRow (H104), and the result of the {=MAX(…))} to ChartEndRow (H105). I concatenated those into a cell, with the calculated ranges listed out in text format, and named the cells XRange (J104) and YRange (J105).

 

How do I get that calculation into the X and Y-Values fields in the chart data dialog box? I tried several approaches, but they all resulted in errors. It doesn't appear formulas [e.g. INDIRECT()] are allowed in the Select Data Source fields.

 

I wanted to avoid VB…

 

Thanks in advance!