I have the following IF statements in a cell that I want to apply to the entire column, rather than each Google Sheets cell. Right now I am copying and pasting the same code to each cell. How do I apply to this my 'I' column so that any cell in that column has this logic? I'm sure there's easier ways of doing this but I'm not good with spreadsheets.
=IF(G:G = "Wipeout", "187.50",
IF(G:G = "Glass Beach", "197.50",
IF(G:G = "Lifeguard Stand 2", "187.50",
IF(G:G = "Misty Bike", "187.50",
IF(G:G = "Sunset Surf", "187.50",
IF(G:G = "Grand Waves", "187.50",
IF(G:G = "Flight", "187.50",
IF(G:G = "Foggy Beach", "187.50",
IF(G:G = "The Cold Shore", "187.50",
IF(G:G = "Palm Tree", "187.50",
IF(G:G = "Pelican", "417.50",
IF(G:G = "Lifeguard Stand", "187.50", ""))))))))))))
With the blue array a Named Range called _nr1, in Row1 (I chose ColumnH):
=ArrayFormula(iferror(vlookup(G1:G,_nr1,2,),""))
gives me the result indicated:
I am not sure if you have gotten the solution that you require but it would be good to have shared the data you need help with. I know that if it is the same function for an entire column, you can apply it to the first cell and then click and drag to apply to the remaining - click and drag to apply a copy across a group of cells.
Related
I do not know how to code and I am trying to learn Pinescript but it really makes no sense to me so i googled how to set a backtest range and used some code someone else wrote but it doesn't seem to be actually testing the area i would like, it tests the entirety of the chart. I'd like to test from 1/1/2018 to present. I'm trying to do this for multiple strategies so I can better tailor them to the current market. here is wat I have for one of them and if you are willing to help with the others I would very much appreciate it!!! feel free to DM me.
//#version=5
strategy("Bollinger Bands BACKTEST", overlay=true)
source = close
length = input.int(20, minval=1)
mult = input.float(2.0, minval=0.001, maxval=50)
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upper = basis + dev
lower = basis - dev
buyEntry = ta.crossover(source, lower)
sellEntry = ta.crossunder(source, upper)
if (ta.crossover(source, lower))
strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE")
else
strategy.cancel(id="BBandLE")
if (ta.crossunder(source, upper))
strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE")
else
strategy.cancel(id="BBandSE")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
// === INPUT BACKTEST RANGE ===
fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromYear = input.int(defval = 2018, title = "From Year", minval = 1970)
I got articles from PubMed, I am using Power BI to visualise How many articles are written by each author, each article is written by many authors as shown in the picture any idea to do that, this is my table structure in power bi. What I want to get is a chart visualising :
name of author: number of articles
One other thing is to visualise collaboration between authors, I mean how many time each pair of authors worked together,
any ideas, I searched about it but not result that I need just an orientation.
First if you want to show how many article writes a specific author then you need a list of authors in one column (if you dont have dictionary then you can create this list as NewTable in dax):
AuthorsList = SUMMARIZE(UNION( VALUES(pubmed[name1]), VALUES(pubmed[name2]), VALUES(pubmed[name3])), pubmed[name1])
Then we can create a measure:
ArticleCount =
var __author = SELECTEDVALUE(AuthorsList[name1])
return
CALCULATE( COUNTROWS(VALUES(pubmed[ID])), FILTER(ALL(pubmed), pubmed[name1] = __author || pubmed[name2] = __author || pubmed[name3] = __author))
And for collaboration, I think we can create a cross join ListOfAuthors and use measures like this one (but I don't test it).
ArticleCount =
var __author = SELECTEDVALUE(AuthorsList[name1])
var __author2 = SELECTEDVALUE(AuthorsList[name2])
var __author3 = SELECTEDVALUE(AuthorsList[name3])
return
CALCULATE( COUNTROWS(VALUES(pubmed[ID])), FILTER(ALL(pubmed),
(pubmed[name1] = __author || pubmed[name2] = __author || pubmed[name3] = __author) &&
(pubmed[name1] = __author2 || pubmed[name2] = __author2 || pubmed[name3] = __author2) &&
(pubmed[name1] = __author3 || pubmed[name2] = __author3 || pubmed[name3] = __author3)
)
)
I am trying to split by date and event columns. It is impossible to search for ". " some lines contain multiple sentences ending with ". " Also, some lines don't start with dates. The idea of the script was to use a regexp to find lines starting with the fragment "one or two numbers, space, letters, period, space" and then replace "point, space" with a rare character, for example, "#". If the line does not start with this fragment, then add "#" to the beginning. Then this array can be easily divided into two parts by this symbol ("#") and written to the sheet.
Unfortunately, something went wrong today. I came across the fact that match(re) is always null. I ask for help in composing the correct regular expression and solving the problem.
Original text:
1 June. Astronomers report narrowing down the source of Fast Radio
Bursts (FRBs). It may now plausibly include "compact-object mergers
and magnetars arising from normal core collapse supernovae".[3][4]
The existence of quark cores in neutron stars is confirmed by Finnish
researchers.[5][6][7]
3 June. Researchers show that compared to rural populations urban red
foxes (pictured) in London are mirroring patterns of domestication
similar to domesticated dogs, as they adapt to their city
environment.[21]
The discovery of the oldest and largest structure in
the Maya region, a 3,000-year-old pyramid-topped platform Aguada
Fénix, with LiDAR technology is reported.
17 June. Physicists at the XENON dark matter research facility report
an excess of 53 events, which may hint at the existence of
hypothetical Solar axions.
Desired result:
Code:
function replace() {
const sheetName = "Sheet1";
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
const lr = sheet.getLastRow();
// const range = sheet.getRange(2, 4, lr - 1);
const range = sheet.getRange(100, 4, 5);
const arr = range.getValues();
const newArr = [];
const re = new RegExp("^([0-9]{1,2}\s[a-z]+\.)\s");
for (let i = 0; i < arr.length; i++) {
const match = arr[i][0].match(re);
if (match == null) {
let newEntry = "#" + arr[i];
newArr.push(newEntry);
} else {
// let newEntry = "#" + arr[i];
// newArr.push(newEntry);
}
}
// range.offset(0,1).setValues(newArr);
// console.log(newArr);
}
function breakapart() {
const ms = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Sheet1');//Data Sheet
const osh = ss.getSheetByName('Sheet2');//Output Sheet
osh.clearContents();
const vs = sh.getRange(1, 1, sh.getLastRow(), sh.getLastColumn()).getDisplayValues().flat();
let oA = [];
vs.forEach(p => {
let f = p.split(/[. ]/);
if (!isNaN(f[0]) && ms.includes(f[1])) {
let s = p.slice(0, p.indexOf('.'));
let t = p.slice(p.indexOf('.')+2);
oA.push([s, t]);
} else {
oA.push(['',p]);
}
});
osh.getRange(1,1,oA.length,oA[0].length).setValues(oA);
}
How can I make it so the formula on E2 reads values entered in any of the search cells and displays it as results, considering I have a button to clear all search boxes and users are instructed to only search one box at a time and to press the button if multiple boxes are filled?
See image
Here's my editable Spreadsheet
Much appreciated.
try:
=IFNA(QUERY(A2:C4; "where A = '"&B6&"'
or B = '"&B7&"'
or C = '"&B8&"'"; 0))
I'd like results to be shown only if the data users look for are in the same row.
=IFNA(QUERY(A2:C4; "where A = '"&B6&"'
and B = '"&B7&"'
and C = '"&B8&"'"; 0))
UPDATE:
=IFNA(QUERY(A2:C4; "where "&TEXTJOIN(" and "; 1;
IF(B6="";;"A = '"&B6&"'");
IF(B7="";;"B = '"&B7&"'");
IF(B8="";;"C = '"&B8&"'"))&""; 0))
You can combine conditions via + and *
=IFNA(
FILTER(A2:C4;(A2:A4=B6)+(B2:B4=B7)+(C2:C4=B8));
"Enter the data for the request"
)
I have a Google Sheets question I was hoping someone could help with.
I have a list of about 200 keywords which looks like the ones below:
**List 1**
Italy City trip
Italy Roundtrip
Italy Holiday
Hungary City trip
Czechia City trip
Croatia Montenegro Roundtrip
....
....
And I then have another list with jumbled keywords with around 1 million rows. The keywords in this list don't exactly match with the first list. What I need to do is search for the keywords in list 1 (above) in list 2 (below) and sum all corresponding cost values. As you can see in the list below the keywords from list 1 are in the second list but with other keywords around them. For example, I need a formula that will search for "Italy City trip" from list 1, in list 2 and sum the cost when that keyword occurs. In this case, it would be 6 total. Adding the cost of "Italy City trip April" and "Italy City trip June" together.
**List 2** Cost
Italy City trip April 1
Italy City trip June 5
Next week Italy Roundtrip 4
Italy Holiday next week 1
Hungary City holiday trip 9
....
....
I hope that makes sense.
Any help would be greatly appreciated
try:
=ARRAYFORMULA(QUERY({IFNA(REGEXEXTRACT(PROPER(C1:C),
TEXTJOIN("|", 1, SORT(PROPER(A1:A), 1, 0)))), D1:D},
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col2)''", 0))
You want to establish whether keywords in one list (List#1) can be found in another list (List#2).
List#2 is 1,000,000 rows long, so I would recommend segmenting the list so that execution times are not exceeded. That's something you will be able to establish by trial and error.
The solution is to use the javascript method indexOf.
Paraphrasing from w3schools: indexOf() returns the position of the first occurrence of a specified value in a string. If the value is not found, it returns -1. So testing if (idx !=-1){ will only return List#1 values that were found in List#2. Note: The indexOf() method is case sensitive.
function so5864274503() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var srcname = "source";
var tgtname = "target";
var sourceSheet = ss.getSheetByName(srcname);
var targetSheet = ss.getSheetByName(tgtname);
// get the source list
var sourceLR = sourceSheet.getLastRow();
var srcData = sourceSheet.getRange(1,1,sourceLR).getValues();
//get the target list
var targetLR = targetSheet.getLastRow();
var tgtlist = targetSheet.getRange(1,1,targetLR,2).getValues();
var totalcostvalues = [];
// start looping through the keywords (list 1)
for (var s = 0;s<srcData.length;s++){
var totalcost = 0;
var value = srcData[s][0]
// start looping through the strings (List 2)
for (var i=0;i<tgtlist.length;i++){
// set cost to zero
var cumcost = 0;
// use indexOf to test if keyword is in the string
var idx = tgtlist[i][0].indexOf(value);
// value of -1 = no match, value >-1 indicates posuton in the string where the key word was found
if (idx !=-1){
var cost = tgtlist[i][1]
cumcost = cumcost + cost;
totalcost = totalcost+cost
}
}//end of loop - list2
//Logger.log("DEBUG: Summary: "+value+", totalcost = "+totalcost)
totalcostvalues.push([totalcost])
}// end of loop - list1
//Logger.log(totalcostvalues); //DEBUG
sourceSheet.getRange(1,2,sourceLR).setValues(totalcostvalues);
}
I also got this one, but it's case sensitive a bit
function myFunction() {
var ss = SpreadsheetApp.getActive();
var sheet1 = ss.getSheets()[0];
var sheet2 = ss.getSheets()[1];
var valuesSheet1 = sheet1.getRange(2,1, (sheet1.getLastRow()-1), sheet1.getLastColumn()).getValues();
var valuesCol1Sheet1 = valuesSheet1.map(function(r){return r[0]});
var valuesCol2Sheet1 = valuesSheet1.map(function(r){return r[1]});
Logger.log(valuesCol2Sheet1);
var valuesSheet2 = sheet2.getRange(2,1, (sheet2.getLastRow()-1)).getValues();
var valuesCol1Sheet2 = valuesSheet2.map(function(r){return r[0]});
for (var i = 0; i<= valuesCol1Sheet2.length-1; i++){
var price = 0;
valuesCol1Sheet1.forEach(function(elt,index){
var position = elt.toLowerCase().indexOf(valuesCol1Sheet2[i].toLowerCase());
if(position >-1){
price = price + valuesCol2Sheet1[index];
}
});
sheet2.getRange((i+2),2).setValue(price);
};
}