Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Sensitivity tables

Hi:

I would like to create a sensitivity table in numbers - excel can automatically do this. is there a way to do this in numbers?

many thanks!
janet

iMac, Mac OS X (10.6.6)

Posted on Feb 11, 2011 2:15 PM

Reply
9 replies

Feb 12, 2011 6:40 AM in response to Flo_Ho

Would be great if one of you was fair enough to explain what is a 'sensitive' table.
We aren't Excel helpers but Numbers ones so, we aren't supposed to know the features of XL !

After a search in Google, I assume that you want to extract a subset of a lot of datas according to a given rule.
If it's really that, it's quite easy to achieve.

Yvan KOENIG (VALLAURIS, France) samedi 12 février 2011 15:31:18

Feb 12, 2011 9:42 AM in response to KOENIG Yvan

I think what is being referred to is a data table, but I'm not sure. A data table lets you vary one or two parameters in your data to see what the result would be. For instance if you have the formula =B2+B3, you could provide a list of values for B2 and it will provide a list of results for each of the B2 values, leaving B3 constant. Or you could vary B2 and B3 and get a table of results. For a simple formula (as in my example), this could be easily created by hand. For a complex table where an entire column/table is the "formula", it would take multiple copies of the column/table to get the same set of results.

Feb 17, 2011 6:05 PM in response to janet123

Hi:

That is correct! A sensitivity analysis lets you know what variables drive the final results in a complex spreadsheet. For example, if I have a spreadsheet to calculate the total value of a project and I have some assumptions in my analysis (e.g. interest rate, growth, customer retention rates etc), I would want to see how much it impacts the final valuation if e.g. I got the interest rate wrong and the interest rate is really 5% instead of 6%.

In excel, I would create a data table which would have two columns. One is the input column with, for example, interest rates of 3%, 4%, 5%, 6%, 7%, and 8% (or whatever I choose). Then I tell excel to create for me a data table where each of these interest rates is plugged into the appropriate place in my model and then excel will populate the second column of the data table for me with what the end valuation is if I had this interest rate.

Right now, I am doing this manually and when you want to run 10+ sensitivity analysis, each with a range of 10 input options, that is a lot of manual work. I am wondering if there is a way to automate this in Numbers. Excel automates it via a data table.

Thanks!

janet

Feb 18, 2011 4:58 AM in response to janet123

Janet,

Numbers has a Format option called Slider, and another called Stepper (as well as the much less convenient Pop-Up), that can be used in your analysis scheme. My favorite is the slider and I suggest that you check it out. You give it Min, Max and Step for the respective cell locations of your variables and scrub away, watching the end result cell. A more sophisticated scheme would be to design your layout to display a matrix of results in the form of first derivatives for defined changes in each variable.

Jerry

Feb 22, 2011 12:28 PM in response to janet123

Thanks - The slider and stepper function look interesting - I have never used them before.

If I understand them correctly, it will let me change a value in a cell. I still think I have to then go through and manually building my sensitivity table output - change the value once, note the new outcome manually. change the value again, note the new outcome manually, etc. etc.

Any ideas?

Thanks
Janet

Aug 28, 2015 2:02 PM in response to Badunit

I had been searching for the same and write an Applescript script that do it. I will appreciate if somebody can help improving the user interaction, the error handling and the speed (it's not a problem if the tables are not big, and you don't need to run it many times).


The script need the document to be open on the sheet that contains the tables you are working with. One table must contain the "model" with the parameters or variables and the formulas. The other must be prepared to receive the results with the values of the parameters on the first column and the first row for the two parameters option. For one parameters and multiple results, the table needs to have the values of the parameter in the first column and the first row may be empty or with the name of the parameter and results.


Below is the script. I test it with a simple model. Here is a screen shot of it:

User uploaded file


on rangeSelection(documentPar, sheetPar, tablePar, messagePar)

tell application "Numbers" to tell documentPar to tell sheetPar

tell tablePar

set selection range to range "A1"


display dialogmessageParwith title "OK & Select"

set waiting to true

repeat while waiting

if selection range is not equal to range "A1" then

if selection range is not missing value then

set waiting to false

set cellName to name of selection range

end if

end if

end repeat

end tell

end tell

return cellName

end rangeSelection


-----Main Script


tell application "Numbers"

set numberOfParam to button returned of (display dialog "Select 1 or 2 parameters for the analisys" buttons {1, 2} default button 1) as number


set ActiveDocum to document 1

tell ActiveDocum

set workingSheet to active sheet

tell workingSheet


-- create a list with the names of all the available tables on the active sheet

set allTables to {}

repeat with tableX in every table

copy name of tableX to end of allTables

end repeat

set DefaultTable to item 1 of allTables


--select the table for the model

set modelTableName to (choose from listallTableswith title "Select & OK" with prompt "Select Model Table" default itemsDefaultTable without multiple selections allowed) as text

set modelTable to tablemodelTableName


--select the table for the results, the sensitivity analysis


set availableTables to {}

repeat with tableX in allTables

if tableX as text is not equal to modelTableName then

copy tableX to end of availableTables

end if

end repeat

set DefaultTable to first item of availableTables

set sensitivityTableName to (choose from listavailableTableswith title "Select & OK" with prompt "Select Results Table" default itemsDefaultTable without multiple selections allowed) as text

set sensitivityTable to tablesensitivityTableName

if sensitivityTable is equal to modelTable then

set alertResult to display alert "Error. Can't select the same table for Model and Results" buttons {"Cancel"} as warning default button "Cancel" cancel button "Cancel"

end if


end tell

end tell

end tell


set oTID to text item delimiters

set text item delimiters to ":"

-- get cell with the parameter X

set explText to "Select Vertical Variable Parameter (X) in table: \"" & modelTableName & "\", after closing this window"

set cellNameX to first text item of rangeSelection(ActiveDocum, workingSheet, modelTable, explText)



if numberOfParam is 2 then

-- get cell with the parameter Y

set explText to "Select Horizontal Variable Parameter (Y) in table: \"" & modelTableName & "\", after closing this window"

set cellNameY to first text item of rangeSelection(ActiveDocum, workingSheet, modelTable, explText)


-- get cell with the result of the function object of the analysis

set explText to "Select the cell with the result in table: \"" & modelTableName & "\", after closing this window"

set cellNameF to first text item of rangeSelection(ActiveDocum, workingSheet, modelTable, explText)


else

--tell application "Numbers"

set numberOfResults to text returned of (display dialog "How many results in the analisys?" default answer 2) as number

--end tell


-- get cells with the results object of the analysis

set cellNamesFn to {}

repeat with n from 1 to numberOfResults

set explText to "Select the cell with result Nº " & n & " in table: \"" & modelTableName & "\", after closing this window"

copy first text item of rangeSelection(ActiveDocum, workingSheet, modelTable, explText) to end of cellNamesFn

end repeat


end if


set text item delimiters to oTID


tell application "Numbers"

tell ActiveDocum

tell workingSheet

tell modelTable


-- create references to cells; this way can set the values of those cells within a tell to other table

set cellXref to a reference to cell cellNameX

if numberOfParam is 2 then

set cellYref to a reference to cell cellNameY

set functResultRef to a reference to cell cellNameF

else


set functNaRef to {}

repeat with n from 1 to numberOfResults

set functRef to (a reference to cell (item n of cellNamesFn))

copy functRef to end of functNaRef


end repeat


end if

end tell



-- backup original cell contents to restore them at the end

if formula of cellXref is missing value then

set buX to value of cellXref

else

set buX to formula of cellXref

end if


if numberOfParam is 2 then

if formula of cellYref is missing value then

set buY to value of cellYref

else

set buY to formula of cellYref

end if



tell sensitivityTable

set numberOfRows to row count

set numberOfCols to column count



-- calculate and fill the results in the analisys table

repeat with rowCount from 2 to numberOfRows

tell column "A"

set value of cellXref to value of cell rowCount

repeat with colCount from 2 to numberOfCols

tell row 1 to set value of cellYref to value of cell colCount

tell row rowCount to set value of cell colCount to value of functResultRef

end repeat

end tell

end repeat


-- restore original contents of parameters X and Y

set value of cellXref to buX-- works the same if buX is a number or a formula

set value of cellYref to buY


end tell

else -- numberOfParam is 1

tell sensitivityTable

set numberOfRows to row count

set numberOfCols to numberOfResults



-- add the necessary columns to the table

if column count is less than (numberOfResults + 1) then set column count to (numberOfResults + 1)



-- calculate and fill the results in the analisys table

repeat with rowCount from 2 to numberOfRows

tell column "A"

set value of cellXref to value of cell rowCount

repeat with colCount from 2 to (numberOfResults + 1)


--tell row 1 to set value of cellYref to value of cell colCount

tell row rowCount to set (value of (cell colCount)) to (value of (item (colCount - 1) of functNaRef))

end repeat

end tell

end repeat


-- restore original contents of parameters X

set value of cellXref to buX-- works the same if buX is a number or a formula

end tell

end if

end tell

end tell

end tell

Sensitivity tables

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.