Set column default value in Google Sheets - date

I have a finance tracking worksheet that has a number of formulas for each row. What I'd like to add is have these formulas replicate whenever a new row is inserted (fill it with a "default value").
Sheet before adding the row:
Sheet after adding the row:
I'd like some of these cells (B28 in this case) to contain a formula. for this row the formula is:
=IF(ISBLANK(C27), "", CONCATENATE(YEAR(C27), "-", MONTH(C27)))

You might want to consider an ArrayFormula. Here's a place for getting detail. In your case, the big trick is knowing that you can run the formula through all of Column C using the notation something like C1:C. Doing it this way is far more self documenting than burying it in a Google function and it's way more general.

Because the formula is the same for all rows, I added a function that just does the following:
function addRow() {
SpreadsheetApp.getActiveSheet().getRange('B7:B').setValue('=IF(ISBLANK(C7), "", CONCATENATE(YEAR(C7), "-", MONTH(C7)))');
}
I set this function to run on a trigger whenever the sheet is edited. The row numbers increment themselves so not problem there either.
Used this SO question for help: Default cell values when Inserting new row in Google Sheets

delete everything in your B column and paste this into B1 cell:
={"Date", ARRAYFORMULA(IF(C2:C<>"", YEAR(C2:C)&"-"&MONTH(C2:C)))}

Related

Link editable field to a certain cell in table figure in MATLAB app designer

I am building an application in MATLAB app designer (2019b), and I am trying to link two blank fields to a table that has only two columns, such that the first field should show the first value (in the first column) in the table and the other should show the last value in the first column in the table.
Example
table:
9 2
3 4
5 6
blank field_1: 9
blank field_2: 5
I am a C++ person, so whenever I am developing, for instance in SFML, I just have one event loop that captures and updates everything - no matter where I press on the window, but, in MATLAB, whenever I press a button - I need to build a separate callback function. Here, I am not calling back anything - I just need to update the value.
Anyone, please help?
Thank you
Here's an example which illustrates how you can achieve the behavior you want.
In the below example, I am creating a uitable in the App startup, and I am defining a callback which updates the table as required when the cells are modified.
function startupFcn(app)
vars = {9,2;3,4;5,6;'blank _field_1:', '';'blank field_2:', ''};
t = uitable(app.UIFigure,'Data',vars);
t.ColumnEditable = true;
t.DisplayDataChangedFcn = #updateTable;
function updateTable(src,~)
src.Data(end-1:end,2:end) = [src.Data(1,1) src.Data(end-2,1)].';
end
end

How to auto-fill the row's column based on the row above?

I have a Google sheet where the 1st row is the date and it will autofill every day. So does the row "Value 1" & "Value 2". Now, I've added manually a row name "SUM" with sum formula.
My question is, how can the row be automated every day so that I do not need to manually drag the formula to the right?
Here's the example sheet:-
https://docs.google.com/spreadsheets/d/1gkKn-tDxosXQGvOdYMj8CupEdG9YXi4sB8PegojDS58/edit?usp=sharing
paste in B1 cell:
=ARRAYFORMULA(TRANSPOSE(TEXT(ROW(INDIRECT("A"&
DATEVALUE("2019-9-1")&":A"&
DATEVALUE(TODAY()))), "d/m/yy")))
paste in B4 cell:
=ARRAYFORMULA(MMULT(TRANSPOSE(ROW(
INDIRECT(ADDRESS(2, 2)&":"&ADDRESS(ROW()-1, MAX(IF(1:1<>"", COLUMN(1:1), ))))))^0,
INDIRECT(ADDRESS(2, 2)&":"&ADDRESS(ROW()-1, MAX(IF(1:1<>"", COLUMN(1:1), ))))))

LibreOffice BASIC function - Copy if over a value to a new sheet

I'm trying to create a simple function on a LibreOffice Calc sheet.
I have a table of information where cells A1:K2 has headings (the cells in Row 2 are merged)
all the information runs from A3:K176
The sheet has various functions running on it already, all I need is one more function.
At first I wanted it to automate when i open, but then i thought running the BASIC macro off of a button might be better, so i can edit and then just hit the button once I'm done.
I have the button linked up to run the macro already, but now im stuck... I have tried many ways of writing the code, but it seems that i am just too green to figure it out.
the last time i ran Excel advanced functions i was in high school.
ok, enough talking...
All I need the macro to do is once I hit the button, I need it to check column K and any value > 1 it needs to take that whole row and copy it then go to a target sheet, clear any data on the target sheet. then copy that set of rows to the next open row in the target sheet. possibly even exporting the result to a .txt file as a bonus.
this is a start...
in future I would like to add another button that will do the same function to a array lower down and put that into a different sheet.
Option Compatible
Sub SWD_AwakeningsTrade
Dim i, LastRow
LastRow = Sheets("Card_List").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Awakenings For trade").range("A2:I500").clearContents
For i=2 to LastRow
If Sheets("Card_List").Cells(i,"K").Value = "(>1)" Then
Sheets("Card_List").Cells(i, "K").EntireRow.Copy
Destination:=Sheets("Awakenings For trade").Range("A" & Rows.Count.end(xlUp)
End if
next i
End Sub

How to replace crosstab cell's value with a string

I have column fact, it can carry some difference values:
- Positive values - real values, need to be outputted as is
- 0 is null, output as is
- -1 - special value. Need to ouput "VAC" string in cell.
- -2 - special value. Need to output "SICK" string in cell.
I tried to do it with editing dimension, i replace it with:
case
when [BaseEmp].[FACT_VALUE] = -1 then 'VAC'
when [BaseEmp].[FACT_VALUE] = -2 then 'SICK'
else to_char([BaseEmp].[FACT_VALUE])
end
But now I see error: ORA-01722 invalid number (i think, because strings cannot be aggregated). In column properties I select "min" as aggregate function.
How to replace my special values with strings?
You don't need to change value to VAC, SICK etc.
You need to change DISPLAYED value.
Unlock the padlock in RS.
Select text in your cell
Set text source to "Report Expression"
Write expression like
CASE
WHEN cellValue() = -1 THEN 'VAC'
WHEN cellValue() = -2 THEN 'SICK'
WHEN cellValue() = 0 THEN ''
ELSE cellValue()
END
I tried thinking of a work around regarding your problem. I'm not really sure what you crosstab looks like but considering your parameters above, try creating a data item which holds your case condition for your fact.
Ex.
case
when [BaseEmp].[FACT_VALUE] = -1 then 'VAC' <--- this will produce Any Error Characters
when [BaseEmp].[FACT_VALUE] = -2 then to_char([BaseEmp].[FACT_VALUE]/0) <--- this will produce Missing Value Characters
else to_char([BaseEmp].[FACT_VALUE]) <---- as is
end
Then set the data item's Data Format to number and set the values for the properties as follows:
Kindly give this a try and hopefully it can somehow resolve you problem. Cheers!
Nikita Kuhta checkout Alexey's Baturin's answer. I think it's the appropriate approach. Just one thing if you unlock and select the text in the cell, all of the cell values will be selected and affected by the report expression. You might have several columns or other fact items in the crosstab. If that's the case, what you can do is
Unlock the Report.
Select the crosstab cell/intersection you want to change.
Set the Define Content to Yes.
Drag a Layout Calculation in the crosstab cell/intersection, then insert your case statement.
Thanks to a friend who told be about the define contents. :D

Issue while editing a Table using SWT TableEditor

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet88.java
In the Table Editor example described in the above link, EDITABLECOLUMN is set to "1", i.e. edit second column of the table.
If i want to edit the first column i changed that variable to "0", and when i try to edit that column(1st) in the table, the second column value disappears. I mean the Text widget which is being created so as to serve as a listener for the cell, it occupying the next column as well.
Do you perhaps have following line in your code?
editor.minimumWidth = 250;