Is there a script i can run in google sheets, which would allow me to report on how many emails.
I have from a label within gmail for a timeframe of say 1 month?
eg: label1 = 50 label 2 = 20 label 3 = 34 etc..
I don't need to know the contents or anything else of the emails just a report on how many.
I have tried to find gmail scripts but i cant find a specific one for this.
Related
It's not hard to do this with custom function, but I'm wondering if there is a way to do it using a formula. Because datas won't automatically update when using custom function.
So I have a course list sheet, each with a price. And I'm using google form to let users choose what courses they will take. Users are allowed to take multiple courses, so how many they will take is unknown.
Now in the response sheet, I have datas like
Order ID
User ID
Courses
Total
1001
38
courseA, courseC
What formula to put here?
1002
44
courseB, courseC, courseD
What formula to put here?
1003
55
courseE
What formula to put here?
and the course sheet is like
course
Price
A
23
B
33
C
44
D
23
E
55
I want to output the total for each order and am looking at using FILTER to do this. Firstly I can get a range of unknown length for the chosen courses
=SPLIT(courses, ",") // having named the Courses column as "courses"
Now I need to filter this range against the course sheet? not quite sure how to do it or even if it is possible. Any hint is appreicated.
try:
=ARRAYFORMULA(IF(A2:A="",,MMULT(IFERROR(
VLOOKUP(SPLIT(C2:C, ", "), {F1&F2:F, G2:G}, 2, 0))*1,
ROW(INDIRECT("1:"&COLUMNS(SPLIT(C2:C, ", "))))^0)))
demo spreadsheet
As I need time to digest #player0's answer, I am doing this in a more intuitive way.
I create 2 sheets to store intermediate values.
The first one is named "chosen_courses"
Order ID
User ID
1001
=IFERROR(ARRAYFORMULA(TRIM(SPLIT(index(courses,Row(),1),","))),"")
1002
=IFERROR(ARRAYFORMULA(TRIM(SPLIT(index(courses,Row(),1),","))),"")
1003
=IFERROR(ARRAYFORMULA(TRIM(SPLIT(index(courses,Row(),1),","))),"")
In this sheet every row is a horizontal list of the chosen courses, and I created another sheet
total
course price
=IF(isblank(order_id),"",SUM(B2:2))
=IFERROR(VLOOKUP('chosen_courses'!B2,{course_Names,course_price},2,false),"")
=IF(isblank(order_id),"",SUM(C2:2))
=IFERROR(VLOOKUP('chosen_courses'!B2,{course_Names,course_price},2,false),"")
=IF(isblank(order_id),"",SUM(D2:2))
=IFERROR(VLOOKUP('chosen_courses'!B2,{course_Names,course_price},2,false),"")
course_Names,order_id and course_price are named ranges.
This works well, at least for now.
But there is a problem:
I have 20 courses, so in the 2nd sheed, there are 21 columns. And I copy the formulas to 1000 rows because that is the maximum rows you can get to using ctrl+shift+↓ and ctrl+D. Now sometimes when I open the sheet, there will be a progress bar calculating formulas in this sheet, which could take around 2 mins, even though I have only like 5 testing orders in the sheet. I am afraid this will get worse when I have more datas or when it is open by old computers.
Is it because I use some resource consuming functions? Can it be improved?
I have a sheet that lists through filenames of an image gallery. Each row represents a new image; has a unique filename, but has an associated non-unique page title, as follows:
title
filename
Page 1
img1.jpg
Page 1
img2.jpg
Page 1
img3.jpg
Page 2
img4.jpg
Page 2
img5.jpg
Page 2
img6.jpg
What I need to do is concatenate each file name into a single cell, (formatted in a particular way), as follows:
title
filename
Page 1
img1.jpg///img2.jpg///img3.jpg///
Page 2
img4.jpg///img5.jpg///img6.jpg///
I have tried everything I can think of using COUNTIF, UNIQUE but I can't seem to get anywhere.
I would just write a basic formula for if A1 = "Page 1"... but I have thousands of rows to do so it would take me days and days to write them all out manually changing the formula.
Oh wise wizards of Stackoverflow, please work your wizened magic and help me out with a formula? I have no idea how to use VBA but am willing to poke around if necessary.
Many many thank-yous!
Assuming the datarange in A2:B, try
=arrayformula({unique(A2:A), trim(transpose(query(if((transpose(unique(A2:A))=A2:A)*len(A2:A), B2:B&"///",),,50000)))})
Change range to suit and see if that works?
If you don't want to have any spaces in the output, try
=arrayformula({unique(A2:A), substitute(trim(transpose(query(if((transpose(unique(A2:A))=A2:A)*len(A2:A), B2:B&"///",),,50000)))," ",)})
I have a cell that contains a number range, say 50-60 that I would like to apply custom number formatting to. Ideally, I'd like to be able to format that to output 50Hz-60Hz.
The syntax that works for a regular integer is #"Hz", but I can't find an in-built way to do this for dashed ranges, and I suspect it isn't possible.
Answer:
As you suspected, this isn't possible to do.
More Information:
As Tanaike has said in his above comment, the cell input 50-60 is a string - purely read as text as it contains the - character. Resultantly, Sheets does not have the functionality to use Number formatting to change the way this is displayed.
(Kind of) Workarounds:
Disclaimer: These suggestions are not perfect workarounds and depending on how the data in the cells is processed elsewhere in the sheet, these may not work. They do however provide solutions if you are looking to affect the UI only.
Workaround 1: Using a custom Number Format
You can use the format ##"Hz-"##"Hz" which will display 50Hz-60Hz for the example you give, if the input of the cell is 5060 rather than 50-60. You will however need to change the format to contain three # characters if the frequency range of the cell goes above 100:
##"Hz-"##"Hz" will make the number 5060 display as 50Hz-60Hz
###"Hz-"###"Hz" will make the number 120130 display as 120Hz-130Hz
####"Hz-"####"Hz" will make the number 14201430 display as 1420Hz-1430Hz
Workaround 2: Using an onEdit(e) Trigger
If inputting the - yourself is important, then you can use an onEdit() Apps Script trigger to change the format of the cell to include the Hz unit after-the-fact.
For this workaround, I will assume that the column your frequency ranges are in is column C.
From the Tools > Script editor menu item, you can create a function with the following code:
function onEdit(e) {
if (e.range.getColumn() != 3) {
return;
}
else {
var f = e.value.split("-");
e.range.setValue(f = f[0] + "Hz-" + f[1] + "Hz");
}
}
Make sure to change the value on the line if (e.range.getColumn() != 3) to be whichever column your frequency ranges are: this example uses the value 3 because the column is assumed to be column C, but column D would be 4, E would be 5, etc.
Save the script with the save icon, press the run button (►), and confirm the authentication of running the script.
This will automatically run whenever a value like 50-60 is inputted into column C, and will change to display 50Hz-60Hz instead.
Workaround 3: Using a Custom Function
Google Sheets allow you to write custom formulae that work in a similar way to the built in formulae like =SUM() or =COUNT().
Following the same steps as in workaround 2 to open the Script editor, create the following function:
function hertzify(f) {
f = f.split("-");
return f[0] + "Hz-" + f[1] + "Hz";
}
This does a similar thing as workaround 2, but instead of automatically changing the values of whatever is in a specific column, you call the function by entering the following formula in a cell:
=HERTZIFY("50-60")
This will change the cell's display value to 50Hz-60Hz like before.
You can also use this on other cells; for example if cell C3 has the text 120-130 and in cell D3 you input =HERTZIFY(C3), then D3 will display 120Hz-130Hz.
Feature Request:
As the above workarounds either process the cell data as if they are text or require the number to be formatted in a specific way, they might not be perfect workarounds for all situations.
In this case I suggest filing a feature request with Google for the ability to define a number format for a range of values in a specific cell.
You can do this by either following the Help > Report a problem menu item from the Google Sheets user interface, or make a feature request on Google's Issue Tracker asking to implement this as a feature. The link to the Issue Tracker is here
References:
Format numbers in a spreadsheet - Computer - Doc Editors Help
Simple Triggers | Apps Script | Google Developers
Custom Functions in Google Sheets | Apps Script | Google Developers
Google's Issue Tracker
I am currently creating a dashboard in Google Sheets.
In cell A2, one can select from two views (let's say "test" and "test2").
In A5 they can pick a starting date and in A8 one can fill in the end day.
In cells A10:C17 I have some mock-up data (see below).
Now what I want is to display the data between two dates and based on the views (in the table called selector. Users can select test and test2). I am able to use Filter() to filter the dates, however, I am unable to select a view. Thus I can only use it for the dates, not for the views.
This is the formula that allows me to filter the dates:
=arrayformula(ifs($A$2="test";1)*FILTER(A11:C17;A11:A17>=A5;A11:A17<=A8))
Anyone any idea on how to use an IF (or any other function that might work) to allow me to select between the views?
Mock-up data:
Selector
Test
Start date
01-01-2018
End date
03-01-2018
Date Users Pageviews
04-01-2018 350 400
03-01-2018 300 350
02-01-2018 250 300
01-01-2018 200 250
31-12-2017 150 200
30-12-2017 100 150
29-12-2017 50 100
If you want you can view the spreadsheet here: https://docs.google.com/spreadsheets/d/e/2PACX-1vRjwsm49p48sP2dZXWjdMacw9vLe0GoADLKc_J4E2Sggo5hDpp2a_2zpCsZM4jlW21CfLrG_TSthhV7/pubhtml
In A10:C17 you can see the data I want to show for test and in A20:A27 you can see the data I want to show for test2.
Sample File
=if(
A2="test",
formula_1,
if (A2="test2", formula_2, "Other")
)
In the formula above, if a user selects:
"test", then the result is formula_1,
"test2", then the result is formula_2,
else the word "Other" will appear
Replace:
formula_1 with FILTER(A11:C17;A11:A17>=A5;A11:A17<=A8)
formula_2 with a formula for the second view.
This works for a combined "view" drop down. If you want to separate the view options to get a side-by-side comparison, that should be no problem.
Filter
=IF(A2="test",FILTER(A11:C,A11:A>=A5,A11:A<=A8),IF(A2="test2",FILTER(A11:C,A11:A>=B5,A11:A<=B8),"Sorry. No matches found"))
Selected dates minus 1 year
=DATE(YEAR(A5)-1,MONTH(A5),DAY(A5))
See this Google Sheet
The dates ranges in the drop downs are just data validation based on the spreadsheet data.
I have a spreadsheet of my department's priorities and initiatives for the year, it has about 10-15 columns. I'd like to create a series of executable buttons to place at the top of the report for easy access to filtering the sheet by certain values. For example, one button may say "show completed items" and when clicked the script would sort the "Status" column show only the rows with completed as the value in that column. The trick here is that I want these filters to run by clicking on the image so they would need to be done in script. I'm a beginning user of scripts so any help would be much appreciated.
In my sheet these are the column headers
Col 1 Pillar
Col 2 Strategy
Col 3 Initiative
Col 4 Priority
Col 5 Quarter Delivered*
Col 6 P&C Owner
Col 7 Partners
Col 8 Current Status
Col 9 Start Date
Col 10 End Date
Col 11 Status Notes
Thank you
The best way is to save your filters. Saved filters are accessible by all viewers.
For steps on how to do this, go to Filter your data, scroll down so you see "Create, name, and save a filter view", then select "Create and save filter view"
After you saved your filter views, you can access them from the drop down menu on the filter button.
Google has some great documentation for their Apps Script, which includes help with writing scripts for Google Sheets. Just go here and click "Build an add-on", and I'm sure SO would be glad to help once you come up with some more specific programming questions.