Log date on cell text change in Google Sheets - if-statement

I'm trying to log the date in a cell when a user tries to enter a text in another cell. To give you a clearer picture, I would like today's date to be logged in cell B1 when a user writes something in A1. I used this formula in B1:
=IF(A1="","",B1=TODAY())
but it doesn't work! Any idea how I can do this?

paste this in B1 cell:
=IF(A1=""; ; TODAY())
note: the date will change daily
_______________________________________________________
otherwise, it would be:
function onEdit(e) {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet1" ) { // SHEET NAME
var r = s.getActiveCell();
if( r.getColumn() == 1 ) { // COLUMN OF ENTRY
var nextCell = r.offset(0, 1); // OFFSET +1 COLUMN
var newDate = Utilities.formatDate(new Date(),
"GMT+8", "MM/dd/yyyy"); // TIMEZONE + DATE FORMAT
nextCell.setValue(newDate);
}}}

Related

How to Move a Row to Two Different Locations on a Different Google Sheets Tab Based off Two Different Criteria

I would like to copy and paste a row from one google sheet tab titled "New Projects" to another google sheet tab titled "Project Tab" if column H says "Approved" and then clear the row that was copied. Additionally, I would like the destination of the copied row on the tab titled "Project Tab" to be conditional on column G on the tab "New Projects" before the copy and paste function is made. If column G says either "4" or "5" I would like to copy and past the row to row 8 on the tab called "Project Tab", else copy and paste the row to row 60 the tab called "Project Tab". So in summary: If column H says "Approved" in the "New Projects" tab check to see if column G has either a "4" or a "5". If it does move to row 8 on the tab called "Project Tab", else move to row 60. Below is a pictures of:
"New Projects" Tab
Top of "Project Tab" Tab
Bottom of "Project Tab" Tab"
I have created separate working function for sorting the rows once they are copied to the "Project Tab" tab. These functions are listed below in the picture:
Sorting Functions
The code below represents what I currently have. Right now it is copying the rows from "New Projects" tab and pasting in the "Project Tab" tab at row 8 regardless of what column G says on the "New Projects" tab. This is where I need help. How can I create a code that copies and pastes to a specific location based on column G, but the function does not run until it reads "Approved" in column H?
function onEdit(event){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
newprojectstoProjecttab(ss,s,r);
}
function newprojectstoProjecttab(ss,s,r){
if(s.getName() == "New Projects" && r.getColumn() == 8 && r.getValue() == "Approved") {
var row = r.getRow();
var targetSheet = ss.getSheetByName("Project Tab");
var target = targetSheet.getRange(60,1,1);
var prioritytarget = targetSheet.getRange(8,1,1);
if(r.getColumn() == 7 && r.getValue() == "4" || "5") {
s.getRange(row, 1, 1, 7).copyTo(prioritytarget);
var clearRange = s.getRange(row,1,1,8);
clearRange.clearContent();
} else {
s.getRange(row, 1, 1, 7).copyTo(target);
var clearRange = s.getRange(row,1,1,8);
clearRange.clearContent();
}
}
}
Any help would be much appreciated! If you need more information please let me know!
the first IF is sheet="New Products" and Column H = "Approved"
the second IF is the value of Column G: if (ColGValue == 4 || ColGValue == 5){
if true, then the target is column 8: var target = targetSheet.getRange(8,1,1)
if false, then the target is Column 60: var target = targetSheet.getRange(60,1,1)
thereafter, the commands are identical
copy the data to the target: s.getRange(editedRow, 1, 1, 7).copyTo(target)
erase the source: s.getRange(editedRow,1,1,8).clearContent()
var ss = spreadsheetApp.getActiveSpreadsheet()
var s = event.source.getActiveSheet()
// get the edited row, and the values of Column G and H
var editedRow = event.range.rowStart
var ColHValue = s.getRange(editedRow,8).getValue()
var colGValue = s.getRange(editedRow,7).getValue()
if(s.getName() == "New Projects" && ColHValue == "Approved") {
var targetSheet = ss.getSheetByName("Project Tab")
if (ColGValue == 4 || ColGValue == 5){
// if Column G =4 or 5, copy to row 8
var target = targetSheet.getRange(8,1,1)
}
else
{
// if Column G <> 4 or 5, then copy to row 60
var target = targetSheet.getRange(60,1,1)
}
s.getRange(editedRow, 1, 1, 7).copyTo(target)
s.getRange(editedRow,1,1,8).clearContent()
}

MdxScript(Model) cslculation error in measure : A table of multiple values was supplied where single value was expected

İ want to find sufficient stock according to sale.
Measure =
VAR _date = VALUES(dateofdata)
VAR opening_date = VALUES('Stores' [Opening date])
VAR dayfornewstores = _date-opening_date
VAR _days = 28
VAR avg_sales = IF(opening_date<28,[TotalSales]/opening_date,[TotalSales]/_days)
VAR qual_days = [TotalStocks]/avg_sales
RETURN qual_days
When I use this measure in table for each store it is success. But when I want all of my stores number of days to qualify for sale in card visual there is error. How can I solve it?

DAX Power BI - addcolumns to calculated table

I have a task to compare 2 dynamic periods from the table (MOO).
Th idea is to get clients which are in both dates and compare them by 1 field (Rating_rank).
But my created field calculates max from all table, not grouping by client.
What should id do?
rate_worse_tab =
var min_dt = calculate(min('MOO'[value_day]),ALLSELECTED('MOO'[value_day]))
var max_dt = calculate(max('MOO'[value_day]),ALLSELECTED('moo'[value_day]))
var cur_cl = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO,MOO[VALUE_DAY]=max_dt))
var old_cl = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO,MOO[VALUE_DAY]=min_dt))
var combo_table = CALCULATETABLE(values(MOO[CLIENT_UK]),filter(MOO, MOO[CLIENT_UK] in cur_cl && MOO[CLIENT_UK] in old_cl))
var f_table = ADDCOLUMNS(combo_table,"Old_rate_rank",calculate(max(MOO[Rating_rank]),filter(MOO,MOO[VALUE_DAY]=min_dt && MOO[CLIENT_UK] in combo_table)))
return
f_table

How to create a new column based on previous row with DAX - PowerBI

Hi on powerBI I have something like this
Desire result is this to create another column 'is_repeat from previous row'
where it is 'True' when the current row is repeat the top row
I tried to use 'EARLIER' function to compare current row to previous but EARLIER grey out my 'index' column - not sure why
thanks in advance!
Calculated Column:
=
VAR ThisIndex = Table1[INDEX]
VAR PreviousIndex = ThisIndex - 1
VAR ThisCode = Table1[code]
VAR PreviousCode =
LOOKUPVALUE( Table1[code], Table1[INDEX], PreviousIndex )
RETURN
ThisCode = PreviousCode

Apex Interactive Grid how to retrieve a specific record

I am retrieving my grid data using:
var ig$ = apex.region("myGrid1").widget(),
view = ig$.interactiveGrid("getCurrentView");
Now I want to check for a specific record based on 2 columns: id1 and id2 where id1 = 1 and id2 = 7
How can I do that with javascript?
You can iterate for each record like this:
//"myGrid1" should be the static id of the IG region
var widget = apex.region('myGrid1').widget();
var grid = widget.interactiveGrid('getViews','grid');
var model = grid.model;
var results = [];
model.forEach(function(r) {
var record = r;
//the name of the columns should be ID1 and ID2, if not
//make the necessary changes using "_" to represent "space"
var value1 = model.getValue(record,'ID1');
var value2 = model.getValue(record,'ID2');
if(value1 == 1 && value2 == 7) {
results.push(record);
}
})
console.log(results);
To test this code, execute it on console.
To start the console on chrome just press F12
good luck.