Calculate how many years there's left on a debt and print it in date format - date

I'm using Google Docs Spreadsheet and I want to calculate how many years there is left on a debt from a fixed date (YYYY-MM-DD), into a date (same formation).
Example: I started to pay off on a debt which are on 20 000, 2014-03-31. Every month, I'll pay 200 and the debt will be payed off 2022-03-31. If I change the pay sum (200) to another sum, the date will be based on the new sum and change the final debt year.
How can I accomplish this?

If you are satisfied with a more or less exact solution, you can write:
=A1+(30*D1/D2)
where:
A1 is your starting date (in date format), such as: 2014-03-31
D1 is your total amount of debt, in this example: 20000
D2 is your monthly sum of debt payed, in this example: 200
The formula simply counts how many months you need to clear the debt (D1/D2, which gives 100), and then multiples it by the average days of a month (30). Then it adds this amount of days to the starting date. Actually this example gives the result: 2022-06-17 as the final clearance of the debt.
As I said it's not fully exact as it counts 30 days as an average month and it does not count loop years, but I think that it can be used for your purpose.
I hope it helps.
UPDATE:
You'll get a little closer result to the exact value, if you use this:
=A1+(365*quotient(D1/D2,12))+(30*MOD(D1/D2,12))
The QUOTIENT function will calculate how many years are needed (in the example D1/D2 divided by 12). We multiply this value with 365 (the number of days in a year).
Then the MOD function calculates how many more months are needed after the years, which is the modulo of "D1/D2 divided by 12".
This function will give 2022-07-27 as a result for this example.

Related

Google Sheet - calculating attendance from moving date range

Good day folks, we have a Google Sheet with training attendance. We are meeting on weekly basis and calculate attendance from the past four months, last 36 month and historical total.
Situation: Currently, we calculate the attendance by assigning 2 (double training)/1 (normal training)/0 (canceled training) to the value of the training and attendee (2 on double, 1 on normal, 0 when absent) - and get attendance percentage by comparing the person's points sum to that of the trainings during the given period (4 months, 36 months, total).
Issue: The problem is that every time we add a training (new row in the tab), we need to manually change date range in the 4 month calculation and end date in the 36 months. I would love to automate this process that every time we add a new column, we would not have to change the date range.
Cells:
C4 = maximum points available per trainings in the last 18 months
D4 = maximum points available per trainings in the last 4 months
C5 and below = user's attendance in the past 18 months (his points generated in that timespawn/total available points*100)
D5 and below = user's attendance in the past 4 months (his points generated in that timespawn/total available points*100)
E3:3 = cells with dates when we have trainings
E4:4 = points awarded per that specific training
E5:5 and below = points gained by the member per attendance
Question: is there any way count a number of training points gained in the past 4/18 months by a specific person?
Thank you kindly
try:
=SUM(FILTER(E5:5; E$3:$3>=TODAY()-120; E$3:$3<=TODAY()))/D$4

What is the correct order for substracting from a date

I just stumbled on an interesting problem when trying to calculate birthday from age. Basically the idea is to substract a number of years, months and days from the current date. However depending on the order of subtraction eg smaller to larger units or vice versa the result is different.
For example we need to substract 55 years 3 months and 14 days from 2021-01-13
If I subtract the years first the result will be 1965-09-29
If I subtract the days first the result will be 1965-09-30
It all comes from the difference between the number of days in a month. Now I'm wondering which is the generally accepted order.

DAX Calculate Monthly Average

I am trying to create a measure to calculate a monthly average from a set of data that was collected every 15 minutes. I am newer to DAX and am just unsure how to intelligently filter by month without hard setting in the month ID #. The formula I am trying is:
Average Monthly Use:=AVERAGEX(VALUES('Lincoln Data'[Month]),[kWh])
Where kWh is a measure of the total usage in a column
Thanks in advance
DVDV
To get the monthly average usage, You need to sum up the total usage per user and divide by the total number of months for that user.
Without knowing what your tables look like, it's hard to give a very good formula, but your measure might look something like this:
= DIVIDE(SUMX(DataTable, [kWh]), DISTINCTCOUNT(DataTable[Year-Month]))

Rank dates in Tableau

How can I rank dates on Tableau?
By customer, I have a list of codes banked (every code has an ID and an issue day) and I am interested in calculating the number of days between the first banked code and (as exemple) the 10th code (the difference will be calculated on the issue days).
Some people may have 1 code, some 2, some 10, some 100, etc. I'm only interested in calculating this metric when the number of codes banked is > 9.
The result will be, by customer, Code 10 Issue Date - Code 1 Issue Date.
So I expect that most engaged customers will bank 10 codes in 10 days, less engaged customers will bank 10 in more days.
EDIT: added below an example of the data source (first three columns) and the missing fields to be calculated (last two columns)

Trying to Average number of accounts by hour, day of week, and month

I'm in healthcare and we're trying to assess the number of discharges we have per hour of day, but we'd also like to be able to filter them down by day of week, or specific month, or even a particular day of week in a particular month (e.g. " what is the average number of discharges per hour on Mondays in January?")
I'm confident that Tableau can do this, but haven't been able to make the averages show up in my line graph... every time that I convert it from COUNT to AVG, the line simply goes straight. I got close when I did a table calculation to find the Average (dividing the count per hour by the number of days captured in the report), but when I add a filter for either the month or day of week, selecting one of the options of the filter reduces the total number that is being counted, rather than re-averaging the non-filtered items. (i.e. if the average of the 7 days of the week is "10" for a particular hour, and I deselect the first three days of the week, it's now saying that my average for that hour is roughly 6, despite the fact that all of the days are very close to 10 at that hour.)
Currently, my data table has the following columns:
Account#/MonthYear/HourOfDay/DayOfWeek
ex.12345678/ Jan-17 / 12 /Sunday
I would just create a few calculated fields to differentiate the parts of the calendar you might want to filter/aggregate on. Mixing the month and day of the week with filtering is pretty straight forward with the calculated fields. Then do standard summing to get what you are looking for because an average count of records is always one unless you are throwing some other calculation into the mix. I threw a quick example up on Tableau Public for you to get the idea.