Formulas and values in AppleScript and Numbers - numbers

I'm trying to use the value of a cell in Numbers in another place in Numbers.
Using the formula works, but when I use AppleScript to use that value in another formula on a different sheet, I found out it's passing the formula, not the value.
set value of (cell "D2") to "=AVERAGE(E3:E1460)"
set value of n to (cell "D2")
I'm getting "=AVERAGE(E3:E1460)" instead of 14.56 for n.
How do I get the value 14.56?

If you want the value (number, date, text, boolean, or missing value) : The actual value in the cell, or missing value if the cell is empty.
Change:
set value of n to (cell "D2")
To:
set n to value of (cell "D2")
If you want the formula of a cell, use, e.g.:
set f to formula of (cell "D2")

Related

Remove formula from column with python

I am trying to remove the formula from a column in a existing sheet with python.
I tryed to set my formula to None using the column object (column.formula = None)
It does not work and my column object remains unchanged. Anyone have inputs to solve this issue ? Thank you !
This took me a bit to figure out, but seems like I've found a solution. Turns out that this is a 2-step process:
Update the column object to remove the formula (by setting column.formula to an empty string).
For each row in the sheet, update the cell within that column to remove the formula (set cell.value to an empty string and cell.formula to None).
Completing the STEP 1 will remove the formula from the column object -- but that cell in each row will still contain the formula. That's why STEP 2 is needed -- STEP 2 will remove the formula from the individual cell in each row.
Here's some example code in Python that does what I've described. (Be sure to update the id values to correspond to your sheet.)
STEP 1: Remove formula from the Column
column_spec = smartsheet.models.Column({
'formula': ''
})
# Update column
sheetId = 3932034054809476
columnId = 4793116511233924
result = smartsheet_client.Sheets.update_column(sheetId, columnId, column_spec)
STEP 2: Remove the formula from that cell in each row
Note: This sample code updates only one specific row -- in your case, you'll need to update every row in the sheet. Just build a row object for each row in the sheet (like shown below), then call smartsheet_client.Sheets.update_rows once, passing in the array of row objects that you've built corresponding to all rows in the sheet. By doing things this way, you're only calling the API once, which is the most efficient way of doing things.
# Build new cell value
new_cell = smartsheet.models.Cell()
new_cell.column_id = 4793116511233924
new_cell.value = ''
new_cell.formula = None
# Build the row to update
row_to_update = smartsheet.models.Row()
row_to_update.id = 5225480965908356
row_to_update.cells.append(new_cell)
# Update row
sheetId = 3932034054809476
result = smartsheet_client.Sheets.update_rows(sheetId, [row_to_update])

3GPP Cell ID and Cell Type

I was going through the 3GPP documents, different Cell IDs and Cell Types.
CellType Format
CGI MCC+MNC+LAC+CI
ECGI MCC+MNC+ECI
SAI PLMN-ID+LAC+SAC
TAI MCC+MNC+TAC
For Eg:
ECGI Value = 310-260-328290210
TAI Value = 310-260-44615
Was just curious, whether we can find the Cell Type given the Cell ID.
If we can, can anyone point me to any resources?

SUMIF cell has positive number, IF cell contains '0' return result of another cell

I have a Google Sheets that is calculating date values. I would like to enter a formula that decreases the date pulled from a given cell if the cell contains a positive number. However, if the cell contains a zero, I would like it to simply return the value of a cell.
Example:
Col A:
A1: 01/01/2018
A2: 01/01/2018
A3: 01/01/2018
Col B:
B1: 0
B2: 1
B3: 2
Col C:
C1: Return Value of A1 (01/01/2018)
C2: Return Value SUM(A2+B2) (01/02/2018)
C3: Return Value SUM(A3+B3) (01/03/2018)
Please try automatically updated formula:
=ARRAYFORMULA(A1:A10+B1:B10)
Notes:
change ranges to yours
you may modify the formula to get dynamic ranges: =filter(A:A+B:B,A:A>0)
This seems relatively straight forward based on your example? See this google sheet... you just add the date to column b? get the outcome you specified? I'm not sure why you should need an Array as Max has done, but this seems to give the same result: =B1+A1
I did notice that you mentioned DECREASE the date. In that case, wouldn't you just subtract the date based on an if statement? I did that in row 20 with this formula: =if(B20>0,A20-B20,A20)

Use the number in one cell to define another cell

I have a cell whose entry is a variable integer.
I'd like to use this number to define another cell.
For example, if the number is 5, then I want Excel to automatically return the whatever's in cell E5; similarly, if the number is 100, I want Excel to return whatever's in cell E100.
How do I do this?
=INDIRECT("E" & C2)
C2 = 5
INDIRECT returns a value from a cell that is referenced using a string i.e.
"E2", "A1", etc.
The and sign("&") concatenates two strings together.
Use INDIRECT()
Assume you have variable number in cell "F3" and values in column "E"..
Write formula like - =INDIRECT("E"&F3)

SSRS Expression works as cell value expression, but not as background color value expression

I have an SSRS report with a matrix in it, where I needed to display the Growth Percentage in a column group compared to the previous column value. I managed this by using custom code...
DIM PreviousColValue AS Decimal
Dim RowName AS String = ""
Public Function GetPreviousColValue(byval Val as Decimal, byval rwName as string) as Decimal
DIM Local_PreviousColValue AS Decimal
IF RowName <> rwName THEN
RowName = rwName
PreviousColValue = val
Local_PreviousColValue = 0
ELSE
Local_PreviousColValue = (Val - PreviousColValue)/PreviousColValue
PreviousColValue = val
END IF
Return Local_PreviousColValue
End Function
..and then using this as the value expression in the cell..
=Round(Code.GetPreviousColValue(ReportItems!Textbox8.Value,Fields!BusinessUnit.Value)*100,0,system.MidpointRounding.AwayFromZero)
So far so good, this produces the expected value. Now I need to use this expression in a background color expression to get a red/yellow/green but in that capacity it fails.
The background color expression looks like this: =IIF(ROUND(Code.GetPreviousColValue(ReportItems!Textbox9.Value,Fields!Salesperson.Value)*100,0,System.MidpointRounding.AwayFromZero)<=-5,"Red"
,IIF(ROUND(Code.GetPreviousColValue(ReportItems!Textbox9.Value,Fields!Salesperson.Value)*100,0,System.MidpointRounding.AwayFromZero) >=5,"Green"
,"Yellow"))
When I run the report the background color expression only ever returns yellow. As a test I pasted the background color expression in as the cell value and ran it again. Results in the image below
I get no build or run time errors so I'm not sure why this does not work.
After some more searching I found a better Custom Code solution than what I was using to get the Growth Percentage in a column group compared to the previous column value. Besides being simpler to read this version has an added benefit: You can dynamically hide the growth percentage column for your first instance of the column group (because it will always be zero or null) and still get the right values in the 2nd/3rd/4th instance of the column group.
Public Function GetDeltaPercentage(ByVal PreviousValue, ByVal CurrentValue) As Object
If IsNothing(PreviousValue) OR IsNothing(CurrentValue) Then
Return Nothing
Else if PreviousValue = 0 OR CurrentValue = 0 Then
Return Nothing
Else
Return (CurrentValue - PreviousValue) / PreviousValue
End If
End Function
The new function is called like so
=Code.GetDeltaPercentage(Previous(Sum(<expression or dataset field>),"Group ByColumn"), Sum(<expression or dataset field>))
Re: the original question - why does my cell value expression not work when used as the background color expression - I took an easy out and just referenced the cell value.
=IIF(ROUND(Me.Value*100,0,System.MidpointRounding.AwayFromZero)<=-5,"Red"
,IIF(ROUND(Me.Value*100,0,System.MidpointRounding.AwayFromZero) >=5,"Green"
,"Yellow"))