Good afternoon!
I am trying to write a sumifs function that will add up the "Total Gross Income" with the corresponding year and week number
Example
Week Number = 21 && Year = 2021 --> $602.85 ($68.75 + $117.60 + $285.00 + $131.50)
Week Number = 21 && Year = 2022 --> $47.42 ($7.75 + $6.25 + $17.06 + $16.30)
I tried to run this function:
=arrayformula(if(C2="","",sumifs($D$2:$D$9,$C$2:$C$9,C2:C)))
But, it will only return the total sum for the year 2021
Here is a link to a copy of the sheet: https://docs.google.com/spreadsheets/d/1eZbSQD6WxpFyaNw58htAT-d12kHZgIRIFofbdHtN9Ic/edit?usp=sharing
use:
=INDEX(IFNA(VLOOKUP(B2:B&C2:C, QUERY({B2:B&C2:C, D2:D},
"select Col1,sum(Col2) group by Col1 label sum(Col2)''"), 2, )))
Related
Ex. Order Day "1"
Order Month "Jan"
Order Year "2020"
Required Date: 1 JAN 2020
If each of these are separate fields, I would build a text version of the date and wrap it in the DATE() function, but there are probably a dozen ways to do it differently.
DATE( [OrderYear] + "-" + [OrderMonth] + "-" + [OrderDay] )
Let's assume your data is
Step-1: Convert all three fields to string type, if not so.
Step-2: create a calculated field say order date full with the following calculation
DATE(DATEPARSE("dd:MMM:yyyy", [order date] + ':' + [order month] + ':' + [order year]))
get results like this
i need to calculate difference between two date excluding sunday. I have table with dates and i need to calculate number of dates of repeated days from last date.
if i have dates like that
27-05-2017
29-05-2017
30-05-2017
I use this code in script
date(max(Date)) as dateMax,
date(min(Date)) as dateMin
And i get min date = 27-05-2017 and max date = 30-05-2017 then i use in expressions
=floor(((dateMax - dateMin)+1)/7)*6 + mod((dateMax - dateMin)+1,7)
+ if(Weekday(dateMin) + mod((dateMax - dateMin)+1,7) < 7, 0, -1)
And get result 3 days. Thats OK, but the problem is if I have next dates:
10-05-2017
11-05-2017
27-05-2017
29-05-2017
30-05-2017
When use previously code I get min date = 10-05-2017 and max date = 30-05-2017 and result 18, but this is not OK.
I need to count only dates from
27-05-2017
29-05-2017
30-05-2017
I need to get max date and go throw loop repeated dates and if have brake to see is that date sunday if yes then step that date and continue to count repeated dates and if i again have break and if not sunday than close loop and remember number of days.
In my case instead of 18 days i need to get 3 days.
Any idea?
I'd recommend you creating a master calendar in the script where you can apply weights or any other rule to your days. Then in your table or app you can just loop through the dates or perform operations and sum their weights (0: if sunday, 1: if not). Let's see an example:
// In this case I'll do a master calendar of the present year
LET vMinDate = Num(MakeDate(year(today()),1,1));
LET vMaxDate = Num(MakeDate(year(today()),12,31));
Calendar_tmp:
LOAD
$(vMinDate) + Iterno() - 1 as Num,
Date($(vMinDate) + Iterno() - 1) as Date_tmp
AUTOGENERATE 1 WHILE $(vMinDate) + Iterno() - 1 <= $(vMaxDate);
Master_Calendar:
LOAD
Date_tmp AS Date,
Week(Date_tmp) as Week,
Year(Date_tmp) as Year,
Capitalize(Month(Date_tmp)) as Month,
Day(Date_tmp) as Day,
WeekDay(Date_tmp) as WeekDay,
if(WeekDay = '7',0,1) as DayWeight //HERE IS WHERE YOU COULD DEFINE A VARIABLE TO DIRECTLY COUNT THE DAY IF IT IS NOT SUNDAY
'T' & ceil(num(Month(Date_tmp))/3) as Quarter,
'T' & ceil(num(Month(Date_tmp))/3) & '-' & right(year(Date_tmp),2) as QuarterYear,
date(monthStart(Date_tmp),'MMMM-YYYY') as MonthYear,
date(monthstart(Date_tmp),'MMM-YY') as MonthYear2
RESIDENT Calendar_tmp
ORDER BY Date_tmp ASC;
DROP Table Calendar_tmp;
I am trying to create a custom function of given a date in Filemaker, I would like it to determine if this week of fiscal year number is within the first week of quarter else it will calculate the first date next quarter. Our Fiscal year starts on July 1
So for defined requirements our FY starts on July 1 and Qtrs are on week # 1, 14, 27, 40 our weeks go from 1-52 and the week starts on Tuesday (Defined as day 3). If FY starts on Monday than the first week will be from Mon-Tues (Therefore a shortweek) then week 2 will be a full 7 day week.
Example---> If I have a date 09/09/2011 that would be week 11 in Q1, therefore since it is not the first week of the quarter I would like the following date for the next Qtr which would be Wk 14 first date of 9/27/2011. So my evaluation needs to determine whether the given date is within the first week of a qtr (weeks 1, 14, 27, 40) or provide the first week of the next qtr.
Also here is the initial CF I was working with from Brian Dunnings site.
https://www.briandunning.com/cf/147
I know this would be developed in filemaker but there maybe something developed in another language which may apply...
Thanks in advance
Try this as your starting point:
Let ( [
startFY = Date ( 7 ; 1 ; Year ( Datefield ) - ( Month ( Datefield ) < 7 ) ) ;
firstTuesday = startFY - Mod ( startFY - 2 ; 7 ) ;
fiscalWeek = Div ( Datefield - firstTuesday ; 7 ) ; //numbering starts at 0
targetWeek = 13 * Ceiling ( fiscalWeek / 13 )
] ;
firstTuesday + 7 * targetWeek
)
Note that the result is always a Tuesday; you may want to adjust this for the boundary cases of fiscal year start and end. The way it works now, you'll get a result of July 30, 2015 for both June 15, 2015 and July 6, 2015.
I want to calculate age with birth day and current day. result should be "years-month-day".How can i do ? Please help.
i'm try this but not be great
DateDiff(“yyyy”,birthday,currentday)
if current date is 20/05/2015 and birth date is 1/06/1991, result = 24 but it should be 23 years 5 month 19 days
If (Not(isNull({#birthdate}))) Then
ToText(int(DateDiff('d',{#birthdate},CurrentDate())/365.25),0)+' Years '+
ToText(int(remainder(DateDiff('d',{#birthdate},CurrentDate()),365.25)/30),0)+' Months '+
If day(CurrentDate()) < Day({#birthdate}) Then
ToText(day(dateserial(year({#birthdate}), Month({#birthdate})+1,1-1)) - Day({#birthdate}) + Day(CurrentDate()),0) + ' days'
Else
ToText(day(CurrentDate()) - day({#birthdate}),0) + ' days'
No perfect but works nicely.. here is an article to read that might help as well for
calculating birthdays
I have such situation in table:
1 01.02.2011
2 05.01.2011
3 06.03.2012
4 07.08.2011
5 04.03.2013
6 06.08.2011
7
8 02.02.2013
9 04.06.2010
10 10.10.2012
11 04.04.2012
where first column is id (INT) and second column is TEXT in which may be written date in format 'dd.mm.yyyy'.
I would like to get:
1) lowest entered date in whole table and highest entered date in whole table.
2) lowest entered date in year 2012 and highest entered date in year 2012.
Lowest and highest date in year may be a same (like for year 2010) or field may be empty (like in row 7).
I am tying to use TO_TIMESTAMP but unsuccessfully.
Example:
SELECT (TO_TIMESTAMP(mydatetxt, 'DD.MM.YYYY'))
FROM " & myTable & "
ORDER BY (TO_TIMESTAMP(mydatetxt, 'DD.MM.YYYY')) ASC LIMIT 1
Also with BETWEEN I don't get wanted result.
How to write those two queries?
SOLUTION:
Thanks for all suggestions.
Igor's solution is most suitable and simple enough for me.
Dim sqlText As String = "SELECT min(to_date(nullif(mydate,''), 'DD.MM.YYYY')) FROM " & mytable
cmd1 = New NpgsqlCommand(sqlText, conn)
min = CDate(cmd1.ExecuteScalar())
If Not IsDate(min) Then
min = CType(CDate("01.01." & myyear) & " 00:00:00", Date)
End If
fromdate = CType(CDate(min), Date)
sqlText = "SELECT max(to_date(mydate, 'DD.MM.YYYY')) FROM " & mytable
cmd1 = New NpgsqlCommand(sqlText, conn)
max = CDate(cmd1.ExecuteScalar())
If Not IsDate(max) Then
max = CType(CDate("31.12." & myyear) & " 23:59:59.9999", Date)
End If
todate = CType(CDate(max), Date)
Try something like:
SELECT max(to_date(nullif(mydatetxt,''), 'DD.MM.YYYY')),
min(to_date(nullif(mydatetxt,''), 'DD.MM.YYYY'))
FROM table_name;
SELECT max(to_date(nullif(mydatetxt,''), 'DD.MM.YYYY')),
min(to_date(nullif(mydatetxt,''), 'DD.MM.YYYY'))
FROM table_name
WHERE date_part('year',to_date(nullif(mydatetxt,''), 'DD.MM.YYYY')) = 2012;