I have a notes view that shows hundreds of peoples’ ages. I then created a categorized view so I can see how many people are in each age. This works fine.
Problem is, I want to group these ages into five year brackets (I.e. age 0 to 5, 6 to 10,11 to 15,etc)
The field is called ‘age’ and it is a text field.
Is there an easy way to do this?
Thanks in advance.
A simple, brute-force way is to create a formula for your column that is categorized.
#If(Age <= 5; "0 to 5";
Age > 5 & Age <= 10; "6 to 10";
Age > 10 & Age <= 15; "11 to 15";
....
Age > 100; "Over 100"; "Not specified");
Also, I believe you could create a hidden Age column before this one and sort by it to make the categories appear in age order
Related
I’m trying to create a report that has everyday of the month listed as a column and sums the transaction quantity for that day if transactions exist and enters a 0 in the column if no transactions exist for that day.
Example:
Day
1 2 3 … 28 29 30 31
Sales Rep.
John Doe. 5 0 0… 10 15 0 30
Any ideas how to make this work? I thought about extracting the day from the transaction date but I can’t figure out how to get the days without any transactions. I thought about using current date to extract day but then the formulas would change every day. Ugh!! Help me please!
You can do this with 31 formula fields.
To avoid overlapping months add a formula text column with a formula TO_CHAR({trandate}, 'YYYY-MM')
Create a saved search on sales orders that filters to the month of interest and includes sales rep, date, document number and amount (at least)
for each date you want to report on include a formula numberic column with a formula like case when TO_number(TO_CHAR({trandate}, 'DD')) = 14 then {amount} else 0 end. Give it a custom label of the day number (e.g. 14)
Set summary columns as follows:
Sales Rep - Group
Document Number - Count
Formula Text - Group
each Formula Numeric - Sum
That's all you need to do but the 31 formula columns are tedious so when I do this sort of thing I do the following to create a template of the saved search and then add and adjust the date range (e.g. add filters in the displayed filter region)
Open any scripted record. Usually just view a sales order. If the step below fails try in a sales order in Edit mode. You won't be saving or updating the order
Right click and select 'Inspect'. This opens the developer tools
Find the 'console'. You should see some clear space at the bottom.
Copy and paste the text below into the console and press your enter key.
If all went well the script will print a number
You can then take the search title (Daily Rep Sales in the example code) and paste it in the NS global search. If you run the search you'll see the last 30 days of sales totalled by rep. Add and update filters (e.g. for different date ranges or only for last month or only for this month etc) and then make the search public to share it (or share it with certain users etc)
require(['N/search'], search =>{
var dateCols = [];
for(var i = 1; i< 32; i++){
dateCols.push(search.createColumn({
name:'formulanumeric',
summary:search.Summary.SUM,
label:'Day '+ i,
formula: "case when TO_number(TO_CHAR({trandate}, 'DD')) = "+ i + " then {amount} else 0 end"
}));
}
const searchId = search.create({
type:'salesorder',
title:'Daily Rep Sales',
filters:[
['mainline', 'is', 'T'], 'AND',
['trandate', 'onorafter', 'daysago30']
],
columns:[
search.createColumn({name:'formulatext', formula:"TO_CHAR({trandate}, 'YYYY-MM')", summary:search.Summary.GROUP}),
search.createColumn({name:'salesrep', summary:search.Summary.GROUP}),
search.createColumn({name:'tranid', summary:search.Summary.COUNT}),
search.createColumn({name:'trandate'}),
search.createColumn({name:'amount'})
// whatever drill down fields you want without summary
].concat(dateCols)
}).save();
console.log(searchId);
})
I know that I can achieve what I need with a set of extra columns in the PivotTable Data Source, but I wonder if there is an alternative way to achieve this.
I have a table with Customers Orders; for each order (i.e. each row) I have the customer name and the indication of the nr of days since last order.
I am trying to put up a PivotTable that has the Customer names in the rows, the nr. of orders in the values and the following groups in the columns:
a) < 7 days
b) 7 <= days < 14
c) 14 <= days < 28
d) >= 28 days
So far, using the "group field" option, I could create the following groups:
i) < 7 days
ii) 7 <= days < 14
iii) 14 <= days < 21
iv) 21 <= days < 28
by setting:
Starting at = 7
Ending at = 28
By = 7
I could live with the extra group (iii), problem is that it does not include the group (d); said differently the grouping acts like a filter which is not what I want.
As said I can add columns for groups a-d, but is there a way to achieve this without?
As far as I know you can only add one group to a pivot table spaced at a regular interval. What I tend to do in these situations is either add a single column to the data source with a nested if formula or to add a secondary table and use a lookup formula.
For example,
The formula below finds the group in the secondary table where days are greater than or equal to the lower bound AND less than or equal to the upper bound.
=INDEX(Table2[Group],MATCH(1,([#Days]>=Table2[Lbound])*([#Days]<=Table2[Ubound]),0))
Good Morning My Friends. How are you all?
So i need Help with Excel Formula.
I have a Table just like Above , with a lot of Contract Numbers and how much those contracts will pay me monthly.
So I May receive the same value from Month 1 to Month 60 as Contract 1 shows, or this value may escalate, just like Contract 182, which ill receive 13.946,56 during 2 years, than ill receive 15065 monthly for the 3 remaining years. Another ex may be Contract 49 which ill receive in the first year 5.694, than in the second year 6.514, and this escalates every year.
What I need is to Transpose it in another Tab as a "Database" Layout:
In these Tab i need the "Months" showed as Years, and Every Contract have to show the value that will pay me Monthly for FIVE YEARS(Years One to Five).
Theres no Problem to Round the Year (Exemple Month 14 may be Year 1 and 19 May be Year 2).
All contracts have different numbers.
Tried Something like this, didn't solve:
=IF(ROUND(RIGHT(VLOOKUP(R56;Consolidado!Q:BC;2;0);2);0)/12>=S56;V55;VLOOKUP(C56;Consolidado!Q:BC;19+S56-S55+1))
Does anyone has a tip?
Taking the folders as an example:
A: Contacts: 1/2 / 3 / ...
B: Months: "1 to 14" / "1 to 60" / ...
C: Value: 5000/2000 / ...
D: Months Level 2: "15 to 60" / ...
E: Value Level 2: 8000 / ...
then...
G column with title "Limit Months"
=IF(B2="";"";VALUE(MID(B2;FIND(" a ";$B2)+3;99)))
H column with title "Div"
=IF(G2="";0;ROUND(G2/12;0))
I column with title "Limit Months"
=IF(D2="";"";VALUE(MID(D2;FIND(" a ";$D2)+3;99))-G2)
J column with title "Div"
=IF(I2="";0;ROUND(I2/12;0))
K column with title "Indices" <- IMPORTANT
=IF(K1="Indices";"1-0";IFERROR(IF(VALUE(MID(K1;FIND("-";K1)+1;99))<INDEX($H$2:$H$1000;MATCH(VALUE(LEFT(K1;(FIND("-";K1))-1));$A$2:$A$1000;0));MID(K1;1;FIND("-";K1))&VALUE(MID(K1;FIND("-";K1)+1;99))+1;VALUE(MID(K1;1;FIND("-";K1)-1)+1)&"-0");VALUE(MID(K1;1;FIND("-";K1)-1))+1&"-0"))
L column with title "Val1"
=IF(VALUE(MID(K2;FIND("-";K2)+1;99))<>0;INDEX($C$2:$C$10000;MATCH(VALUE(MID(K2;1;FIND("-";K2)-1));$A$2:$A$1000;0));"")
M column with title "Indices2" <- IMPORTANT
=IF(M1="Indices2";"1-0";IFERROR(IF(VALUE(MID(M1;FIND("-";M1)+1;99))<INDEX($J$2:$J$1000;MATCH(VALUE(LEFT(M1;(FIND("-";M1))-1));$A$2:$A$1000;0));MID(M1;1;FIND("-";M1))&VALUE(MID(M1;FIND("-";M1)+1;99))+1;VALUE(MID(M1;1;FIND("-";M1)-1)+1)&"-0");VALUE(MID(M1;1;FIND("-";M1)-1))+1&"-0"))
N column with title "Val2"
=IF(VALUE(MID(M2;FIND("-";M2)+1;99))<>0;INDEX($E$2:$E$10000;MATCH(VALUE(MID(M2;1;FIND("-";M2)-1));$A$2:$A$1000;0));"")
Here an example:
https://drive.google.com/file/d/1rZnhC6-H4xm4AD4uRgsCWJZ7p7oVBZtU/view?usp=sharing
I'm new to Stackoverflow and fairly fresh with Python (some 5 months give or take), so apologies if I'm not explaining this too clearly!
I want to build up a historic trend of the average age of outstanding incidents on a daily basis.
I have two dataframes.
df1 contains incident data going back 8 years, with the two most relevant columns being "opened_at" and "resolved_at" which contains datetime values.
df2 contains a column called date with the full date range from 2012-06-13 to now.
The goal is to have df2 contain the number of outstanding incidents on each date (as of 00:00:00) and the average age of all those deemed outstanding.
I know it's possible to get all rows that exist between two dates, but I believe I want the opposite and find where each date row in df2 exists between dates in opened_at and resolved_at in df1
(It would be helpful to have some example code containing an anonymized/randomized short extract of your data to try solutions on)
This is unlikely to be the most efficient solution, but I believe you could do:
df2["incs_open"] = 0 # Ensure the column exists
for row_num in range(df2.shape[0]):
df2.at[row_num, "incs_open"] = sum(
(df1["opened_at"] < df2.at[row_num, "date"]) &
(df2.at[row_num, "date"] < df1["opened_at"])
)
(This assumes you haven't set an index on the data frame other than the default one)
For the second part of your question, the average age, I believe you can calculate that in the body of the loop like this:
open_incs = (df1["opened_at"] < df2.at[row_num, "date"]) & \
(df2.at[row_num, "date"] < df1["opened_at"])
ages_of_open_incs = df2.at[row_num, "date"] - df1.loc[open_incs, "opened_at"]
avg_age = ages_of_open_incs.mean()
You'll hit some weirdnesses about rounding and things. If an incident was opened last night at 3am, what is its age "today" -- 1 day, 0 days, 9 hours (if we take noon as the point to count from), etc. -- but I assume once you've got code that works you can adjust that to taste.
Good evening all!!
Here's a fun one. I've been pouring through some other posts and it feels like there are many permutations of this scenario but none that span tables, so I'm looking for some input.
Consider the following:
Table A has two fields: ID and TYPE. TYPE will be our value to populate.
ID Type
1
2
3
Table B has two fields: ASSOCIATED ID and HOURS.
Associated ID Hours
1 24
1 0
2 10
2 38
3 50
3 25
The requirement is to return a value of "LESS THAN 25" or "GREATER THAN 25" for TYPE in TABLE A based on the SUM of the HOURS in TABLE B for the ASSOCIATED ID. Ex: ASSOCIATED ID "1" in TABLE has value 24 and 0 for a sum of 24, returning "LESS THAN 25" for TYPE in item ID 1 in TABLE A.
Any and all suggestions will be attempted, thank you so much to the community for taking a look.
Make sure you have a relationship between the two tables by using the ID. Then enter this formula into a column in the ID table:
Type:=if(calculate(sum(TableB[Hours]))>25,"25 or More","Less than 25")
Try this one on 1-TYPE: (I am considering A1 Cell as the beginning of your table for both table, just place the real position)
=IF(SUMIF(TableB!$A$2:$A$7,"="&A2,TableB!$B$2:$B$7)>=25,"GREATER THAN 25","LESS THAN 25")
Then drag it down.