how to distribute a number into numbers of cells? - arrays

I have a sheet for the employees leaves so for example if:
Employee A takes Annual leave for 4 days starting 1/1/2021 I want to distribute the days into cells for these days to be like this:
A | 4 | 1/1/2021 1/1/2021 2/1/2021 3/1/2021 4/1/2021
I want to have each day date into a single cell.
any idea how to achieve that, please

or:
=INDEX(TEXT(SEQUENCE(1, A2, B2), "d/m/yyyy"))

try:
=INDEX(TEXT(TRANSPOSE(ROW(INDIRECT(B2&":"&B2+A2-1))), "d/m/yyyy"))

Or:
=ArrayFormula(B2+SEQUENCE(1,A2,0))

Related

How to extract a handicap value from column based on 2 criteria

Good morning,
I have an issue with extracting the correct handicap value within the following table:
K L M
Handicap York Hereford
0 1287 1280
1 1285 1275
2 1280 1271
3 1275 1268
4 1270 1265
5 1268 1260
6 1265 1258
7 1260 1254
8 1255 1250
9 1253 1246
I also have these 2 lines of sample score/round data:
G H I
Round Score Handicap
York 1269 5
York 1270 4
Hereford 1269 XXX
Hereford 1270 XXX
If for instance someone on a York, gets a score of 1269, they should get a handicap of 5, which this formula achieves:
INDEX($K$7:$K$16,MATCH($H7,$L$7:$L$16,-1))+1
However this formula only works on the one column $L$7:$L$16
Similarly, the 2ns score is calculated with the following formula:
=INDEX($K$8:$K$17,MATCH($H8,$L$8:$L$17,-1))
What I'd like to do is, build that out so if I changed the round to a Hereford, with the exact same score, the cell would automatically calculate that the handicap should be 3.
Is this possible, maybe with an array?
Regards,
Andrew.
With ms365, try:
Formula in I2:
=XLOOKUP(H2,FILTER(L$2:M$11,L$1:M$1=G2),K$2:K$11,"NB",-1,-1)
I would avoid using OFFSET because it is a volatile function.
To select the appropriate column, you can use another MATCH:
MATCH($G7,$L$6:$M$6,0)
will return the column number. This makes it simple if you more than just York and Hereford columns.
Then, to return the matching line:
=MATCH($H7,INDEX($L$7:$M$16,0,MATCH($G7,$L$6:$M$6,0)),-1)
Note the use of 0 for the Row argument in the INDEX function which will return the entire column (all the rows).
Since your handicaps are sequential, as written this formula returns the same values as does yours. But I don't think it is correct since both formulas return 1 for a 1287 York.
You probably need to subtract one from the result of the formula.
=MATCH($H7,INDEX($L$7:$M$16,0,MATCH($G7,$L$6:$M$6,0)),-1)-1
Reference your lookup range with an OFFSET() function, and for the third parameter (which is column offset), use a MATCH() on the headers.
The formula on your first row would be:
=INDEX($K$7:$K$16,MATCH(H7,OFFSET($L$7:$M$16,0,MATCH(G7,$L$6:$M$6,0)-1,ROWS($L$7:$M$16),1),-1))+1

how to query different columns and stack into new table in google sheet

Hi I have columns like so, where it's auto fill every rows.
Where column BCD is from source a, column EFG from source b and HIJ from source c
sheet data
A
B
C
D
E
F
G
H
I
J
1
Date
Name
Cost
Date
Name
Cost
Date
Name
Cost
2
2022-01-02
Alan
5
2022-01-03
James
6
2022-01-02
Timmy
5
3
2022-01-02
Hana
5
2022-01-03
Paul
6
2022-01-02
Jane
5
into
summary sheet
A
B
C
D
E
1
Date
Name
Cost
Source
2
2022-01-02
Alan
5
sourceA
3
2022-01-02
Hana
5
sourceA
4
2022-01-03
James
6
sourceB
5
2022-01-03
Paul
6
sourceB
6
2022-01-02
Timmy
5
sourceC
7
2022-01-02
Jane
5
sourceC
How do I achieve this with formula query, stacking it on top one another.
Source is using if but then how do you detect last row and used it for the if.
the rows for each source might be different.
this is array: {} inside of it you can use comma , to put something next to each other or semicolon ; to put something under something else. eg. having:
={1,2;3,4}
will yield:
A B
------+-------+
1 | 1 | 2
------+-------+
2 | 3 | 4
in that manner you can do:
={QUERY(B:D);
QUERY(E:G);
QUERY(H:J)}
side note: if your locale is non-english then comma , in array is replaced by backslash \
Use array notation to combine the ranges, and combine them with either filter() or query() to remove the empty rows.
Filter docs
Query docs

How do you count cells using regex that do not match the expression?

I want to count the number of cells that do not contain the following words.
denv
univ
du
The above list of words change frequently and in Cell B22 it automatically creates some regex for another formula where I sum another column next to it.
Cell B22 = .*denv.*|.*univ.*|.*du.*
Can I use the same Cell B22 reference for counting everything that DOES NOT contain those words?
Name
Metric
denver
5
ohio
5
dual
9
dual
1
maryland
4
universe
6
maryland
1
dual
2
denver
7
try:
=INDEX(SUMPRODUCT(REGEXMATCH(FILTER(A:A, A:A<>""), B22)=FALSE))
or:
=SUM(INDEX(N(REGEXMATCH(FILTER(A:A, A:A<>""), B22)=FALSE)))

SQL: Windows function

I'm stuck with a new problem
I have two tables:
BudgetNumber Name Remaing(h) EndDate
BU145122 Jhon 5 2018/11/15
BU145123 Jhon 20 2018/12/01
BU145124 Lewis 10 2018/11/15
BU145125 Lewis 50 2018/12/15
Actuals:
Actuals(h) Name DATE
5 Jhon 2018/11/01
6 Jhon 2018/11/10
5 Jhon 2018/11/25
5 Lewis 2018/12/10
So in my final table, I'd like something like:
Name Remaining(h) Date Budget
Jhon 5 2018/11/01 BU145122
Jhon 14 2018/11/01 BU145123
Jhon 9 2018/11/25 BU145123
Lewis 45 2018/12/10 BU145125
So if the date of my budget is lower than my actual date, my budget is lost
If it's not the case, I substract my Actuals from my remaing(Table B)
I can get a table with a windows table but I'm stuck with the date
Is there another way to do that than a loop?
Thanks for your help

Crystal Report - Display Count of differents Details on same line

i have a question on Crystal Report, i have a query that return a list of name that a free slots in the morning and free slots in the afternoon. A person can have 1 or several free slots in the morning or afternoon. The query return something like that:
NAME | HALFDAY
Jean | 1
Jean | 1
Jean | 2
Martin | 2
Martin | 2
Martin | 2
Francois | 1
Francois | 1
Francois | 1
1 is for the morning, 2 is for the afternoon.
So, Jean have 2 free slots in the morning and one in the afternoon.
Martin has 3 free slots in the afternoon.
I would like my report looks like that:
Jean 2 / 1
Martin 0 / 3
Francois 3 / 0
But i don't know how to do that. Any ideas please?
Thanks a lot!
First group by customer
Create multiple formulas like
If halfday=1
Then 1
Else 0
If halfday=2
Then 2
Else 0
Now take the count of every formula in group footer
Take saperate formula in group footer
Write below code
Databasefield.customernam & totext(count of formula1) & "/" & totext (count of formula 2) //so on

Resources