Transforming to Database Layout, VLookup, Round, Months - excel

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

Related

How to sum up to reach a number by date in excel

I would like to make a formula that to do a sum calculation, that confirm which date to start (cell D5), then look for the start point from the row 1, and sum up the row 2 start from the correct date, and then stop the sum up if the amount is equal to or larger than run estimate (cell D6)
the steps should be like this:
I know the start day is 31-May
then I look into the table to find the date 31-May
then I look into the table again, find out the run estimate is 2 hours
I know I have 6 hours run estimate need to be completed
then I add 2 + 3 + 4 = 9 hours to cover the 6-hour estimate
then I know the end date is 2- Jun
I am able to find the start point on the table
=SUMIFS(B2:F2,B1:F1,">="&D5)
but I am not sure how to stop it
and moreover I am not sure how display the final value date, not the total amount..
col B col C col D col E col F
30-May 31-May 1-Jun 2-Jun 3-Jun
1 2 3 4 5
start date 31-May
run estimate 6
expected result should be 2-Jun
enter image description here
anyone can help on this?
Here is a solution that requires one extra row of data, to calculate the sum of run times up until that day: Put this formula in cells B3:F3 (or however many columns you have exactly)
=SUMIF($B1:B1,">="&$D6,$B2:B2)
Then you can find the first value that is equal to or higher than your estimate runtime and use that to offset to the correct date:
=OFFSET(B1,0,IFERROR(MATCH($D6,B3:F3,0)-1,MATCH($D6,B3:F3,1)))

Using Google Sheets (or MS Excel) need formula to sum columns to a third column with conditions

I am developing a hockey scoresheet for my son's youth team. I need to figure out how to sum goals by period. I have up to 16 goals per game. Each is identified by period and some other data not relevant to this question (Jersey, assists, etc.). Once the data is entered, I want to show total goals by period. I need help with this part.
Specifically, I need a formula which will look at column A (Period) and if the condition is met add the value in column B (which will typically, but not always be 1) to column G (Period 1 Total). Also, do the same for columns C & D and E & F. Always adding the value to column G.
Columns A,C,D are the period the goal is scored. Columns B,D,F is the point value added. (In reality, my spreadsheet does this with 16 possible goals, but for illustrative purposes, I'm only showing 3 possible goals.)
So, Column G will have a formula that says,
If A = 1 then add B to G
If C = 1 then add D to G
If E = 1 then add F to G
G could have a result of 0 to 3 depending how many goals are scored.
My belief is that additional Columns H and I will represent periods 2 and 3. These two columns will use the same formula as G, except filtering for "2" or "3" in columns A,C,D.
I hope the examples help make sense of the request. Thank you.
Example 1: 3 goals scored in first period
---Goal 1------------Goal 2-----------Goal 3-------Period 1
Period Goal----Period Goal----Period Goal----Goals
--A--------B--------C-------D---------E-------F---------G
--1--------1---------1-------1----------1-------1----------3
Example 1: 2 goals scored in first period
---Goal 1------------Goal 2-----------Goal 3-------Period 1
Period Goal----Period Goal----Period Goal----Goals
--A--------B--------C-------D---------E-------F---------G
--1--------1---------1-------1---------- ------- ----------2
Example 3: 2 goals scored in first period 1 goal scored in period 2
---Goal 1------------Goal 2-----------Goal 3-------Period 1
Period Goal----Period Goal----Period Goal----Goals
--A--------B--------C-------D---------E-------F---------G
--1--------1---------1-------1----------2-------1----------2
You can use SUMIFS()
=SUMIFS(B3:F3,$B$2:$F$2,"Goal",A3:E3,1)
Turns out it was much easier than I thought. I was overthinking things.
=SUM(IF(A1=1,B1),IF(C1=1,D1),IF(E1=1,D1))
Thanks for viewing. I hope this helps someone else out.

Excel --- Tried many time but fail

enter image description here
I want to sum all these data given in right side to my format. I tried many time and many formulas but some things left every time. Please help
You can achieve most of what you need with a mixture of formulae and a pivot table. But I couldn't quite get everything you wanted, as some of it doesn't make sense. For example, you have 2013 - 2012 - <5 as your first row header, but there are multiple years that give an age less than 5, e.g. 2014 - 2013 - <5 would also be valid. I would suggest hardcoding the years somehow, as they aren't entirely relevant anyway?
Breaking it down into separate problems.
How do I get the Roman number version of the Class?
You could have a massive IF statement, but I went for a VLOOKUP. You could have used the ROMAN built in function, but you can't because your numbering is "first", "second", etc. instead of "1", "2", etc.
So I actually went for both solutions, just to show how they both work. First I created a named table (list object) called "Named" that looks like this:
Class Class Number
First 1
Second 2
Third 3
Fourth 4
etc.
I then used this to VLOOKUP your class names and convert them into numbers. Next I used the ROMAN function to make this into roman numeral format. So I ended up with this (columns E, F and G in my worksheet):
Class Class Number Roman
First 1 I
First 1 I
First 1 I
First 1 I
First 1 I
Second 2 II
Third 3 III
Fourth 4 IV
With formulae:
Class Number - =VLOOKUP(E2,Named,2,FALSE);
Roman - =ROMAN(F2).
How do I get from "Male"/ "Female" to "B"/ "G"?
This was trivial, just =IF(A2="Male", "B", "G") where I have Gender in column A.
How do I get the "age text" so it handles "<5" and ">22"?
My age was in column D, so this was also trivial, =IF(D2<5,"<5", IF(D2>22, ">22", D2)).
Now I have enough data to pivot, so I selected my entire table, which was basically your sample data with calculated columns added to the right. Then I inserted a pivot table and dragged in row/ column headers to make it match your format. This doesn't give you the year columns, but it gives you everything else. For example, just using a few random rows of sample data (as I couldn't be bothered to type it all in):
I went from:
Gender Date of Birth Age Class
Male 06-Jan-14 4 First
Female 07-Sep-11 6 First
Male 01-Jan-12 6 First
Male 31-Dec-12 5 First
Female 01-Oct-11 6 First
Female 16-Nov-10 7 Second
Male 31-Oct-09 8 Third
Male 25-Oct-10 7 Fourth
To:
I II III IV
B G G B B
<5 1
5 1
6 1 2
7 1 1
8 1
Total 3 2 1 1 1
From here you could simply hardcode the columns A and B from your desired final format, as these years aren't actually based on the data?

Excel find date difference between minimum and maximum date in month

I'm trying to fix up a formula I have that's having some issues. It's supposed to track # days invoiced in a month, so the high-level idea is to take the maximum date in a month and subtract the minimum date in the month, and on error subtract the 1st day of the month. My current formula has issues adjust for invoices that may cross months, an example being 1/25 - 2/3 where if this were the only invoice, January should show 7 days invoiced and February would show 3. If there were another invoice from 2/15 - 2/28, I would want Feb to show the maxed invoice days, 14 in this example.
For reference here's what a table could look like:
A B C D E F
start month end month invoice begin invoice end Month Max Days invoiced
jan 1 feb 1 1/25/14 2/3/14 1/1 7
feb 1 feb 1 2/15/14 2/28/14 2/1 14
3/1
etc.........
I tried the formula below but it was erroring out, plus I don't think it will account for gaps in invoices like in my example.:
=IF(B2:B100=X1,MAX(D2:D100),) - IF(A2:A100=X2,MIN(C2:C100),A2)
'where column X is a list of months, X1 = 1/1, X2 = 2/1, etc.
No luck with this formula either, keeps erroring out and giving 0 values:
{=DATEDIF(IF(A2:A100=E2,MIN(C2:C100),),IF(B2:B100=E2,MAX(D2:D100),),"d")}
I appreciate your help!
Not sure exactly what you are looking for but you could probably make use of the EOMONTH() function. Here's an example of it:
=EOMONTH(A2,0)-A2+1
by the way - here is how you would get the start of the month:
=EOMONTH(TODAY(),-1)+1
Try the following per your comment below:
"I think this could be useful but I'm not sure it would work if the invoice end was, say, 2/21 or anytime before the EOM"
=IF(B3>=EOMONTH(A3,0),EOMONTH(A3,0)-A3+1,B3-A3+1)

Working Hours Excel Formula

I need to calculate the working hours elapsed between two dates and times, for example:
Holiday taken between 01/09/2014 and 05/09/2014
5 working days # 8 hours per day.
I need the result to show me how many working hours that would be. For example:
ANNUAL ENTITLEMENT: 89.9 Hours
DATE FROM DATE TO RETURN TO WORK HOURS REQUIRED HOURS REMAINING DATE
01/09/2014 05/09/2014 06/09/2014 40 49.90
I have no idea if this is even possible!
I am assuming these are given cells. if you type in the date to a cell you can click on a new cell and put uptop by the fx this
for example. In C1 you can type this into the fx. Make sure you put the equal sign.
=B1-A1
This is what is the dates in the cells
A1 = 1/9/2014
B1 = 5/9/2014
This will give you 120 which is the total days inbetween.
You will want to get the number of weeks so you can divide by 7.
You will multiply weeks by number of days worked which is 5
Then you want the weeks times 8 hours you can do this in C1
=(B1 - A1)/7 * 5 * 8
which gives you 685.7143
you need to also take into account weekends which a simple subtraction will not do. Firstly find the total number of days:
TOTAL_NUMBER_DAYS = B1-A1 + 1
then calculate how many weekends:
TOTAL_WEEKENDS = WEEKNUM(B1) - WEEKNUM(A1)
finally take the total days and subtract weekends:
NET_TOTAL_DAYS = TOTAL_NUMBER_DAYS - (TOTAL_WEEKENDS * 2)
TOTAL_HOURS = NET_TOTAL_DAYS * 8
I solved this recently and had a working solution initially in Excel 2013. Slightly adapted to work in 2007 (lack of 'Days()' function). We use it for reporting on support tickets (length of time between opening and closing a ticket).
Inputs are "Workday start", "Workday end" from which "Hours worked" and "Hours not worked" are calulated.
Hours worked =HOUR(WorkEnd-WorkStart)+(MINUTE(WorkEnd)+MINUTE(WorkStart))/60
Hours not worked = 24 - Hours worked
Further inputs are a table ("Data") with first two columns "Open" and "Close", which are dateserial cells.
Next column is standard numeric value "Gross hours" =(Data[[#This Row],[Close]]-Data[[#This Row],[Open]])*24
Next column is standard numeric value "Net workdays" =NETWORKDAYS(Data[[#This Row],[Open]],Data[[#This Row],[Close]])
Next column is standard numeric value "Net days" =MAX(1,DAY(Data[[#This Row],[Close]])-DAY(Data[[#This Row],[Open]]))
Next column is standard numeric value "Gross workhours" =IF(Data[[#This Row],[Gross hours]]>0,Data[[#This Row],[Gross hours]]-24*(Data[[#This Row],[Net days]]-Data[[#This Row],[Net workdays]]),0)
Last column is standard numeric value "Total work hours" =IF(Data[[#This Row],[Gross workhours]]<24,Data[[#This Row],[Gross workhours]],Data[[#This Row],[Gross workhours]]-(HoursNotWorked*Data[[#This Row],[Net workdays]]+HoursWorked))
This solution makes it trivial to adjust start and end work times, as well as accounting for any holidays (via a small change to the NETWORKDAYS() function to utilise the optional parameter).

Resources