Google Sheets Financial Year Formula - google-sheets

Using the below formula to calculate the Financial Year from the Date (G) column:
=IF(MONTH(G2)>4,YEAR(G2)&"-"&YEAR(G2)+1,YEAR(G2)-1&"-"&YEAR(G2))
It works for that specific cell - G2 but I'm wanting to apply the same formula to the entire 'Tax Year' column.
image
Tried pulling the box down on right lower corner but this clears my formatting (colours of row etc) and means that the formula won't automatically be applied when I insert a new row.

Try:
=INDEX(IF(LEN(G2:G),LAMBDA(z,IF(MONTH(G2:G)>4,z&"-"&z+1,z-1&"-"&z))(YEAR(G2:G)),))

Related

How to arrange column data associated with dates into calendar grids (ie. 6x7 array blocks)?

I have this spreadsheet with dates and values in Data!E2:E, i want to transpose all the values in the column E to the calendar in Calendar!B5:H10. I need a formula to transpose all the values from column to rows, but every time it gets to the border of the month it jumps a row.
First day of the week is Sunday, everyday i plan to complete Data!E2:E cells with 'Yes' or 'No' and they should show up in the calendar with green or grey cells. So i can keep track of which things i did.
I have been doing this manually but it takes too long, i also tried inserting the function =TRANSPOSE(Data!E2:E366) in the calendar and modifying the number of the row, its saves a little time but its tedious.
Calendar
Data
delete everything you got and use this in B5. then copy B5 and paste to J5, R5, Z5, B13, J13, etc.
=INDEX(IFNA(VLOOKUP(VLOOKUP(SEQUENCE(6, 7),
{SEQUENCE(DAY(EOMONTH(B4&"/2022", ))+WEEKDAY(B4&"/2022", 1), 1, ),
{IFERROR(ROW(INDIRECT("1:"&WEEKDAY(B4&"/2022", 1)))/0);
SEQUENCE(DAY(EOMONTH(B4&"/2022", )), 1, B4&"/2022")}}, 2, ), Data!$A:$E, 5, )))
demo sheet
https://stackoverflow.com/a/67755777/5632629
In B5, put
=arrayformula(if((row(B5:H10)-row(B4)-1)*7+column(B5:H10)-column(B4)+1>=weekday(date(2022,month(B4&1),1)),
if((row(B5:H10)-row(B4)-1)*7+column(B5:H10)-column(B4)+1-weekday(date(2022,month(B4&1),1))<eomonth(date(2022,month(B4&1),1),0)-date(2022,month(B4&1),1)+1,
vlookup(date(2022,month(B4&1),(row(B5:H10)-row(B4)-1)*7+column(B5:H10)-column(B4)+1-weekday(date(2022,month(B4&1),1))+1),Data!$A$2:$E,5,false),
),
))
Spread (ie. copy & paste cell outside formula editor) the formula to the cells directly below your month names, e.g. J5, R5.
Remove placeholder formulae in your sheet and reset existing text formatting to visualize the results.
You can adapt the above to a single formula by adding a check on whether the corresponding cell for month name for a given cell is empty. It is also possible to combined the 2 if() conditions if you so desire. In addition, I recommend storing the year number of your calendar in a cell and then referring to that cell, instead of hard-coding 2022.

Google Sheets formula to be applied in rows where there is only numbers

I have a Google Sheets workbook, have lot of data in it in the following way as shown in the picture:
So What I want to do is to highlight all rows in which LDCP > Current (Displayed in green), that is fine when I use conditional formatting and add a formula. But since there are 1000s of such rows, what I want to do is to select all and apply that formula however when I do that it highlights the rows with text such as Leasing Companies and Leather & Tanneries.
Is there a way that I can select the whole sheet and apply a formula which only is applicable where the B column (LDCP) and F Column (Current) consists of numbers. This way only those rows will be highlighted and not the other ones.
Any other kind of advice to do this would be appreciated as well.
Regards,
~K
Try this in your conditional formatting custom formula:
=and($B1>$F1,isnumber($B1))
Range A1:Fnnn where nnn is the end of your sheet.

Google Sheets Conditional formatting based on another sheet

I built a Google Spreadsheets tracking the price of certain items in each month. The different items are displayed in row 3:30. Different retailers are displays in Column C:M. Each month is displayed in a different sheet. I want to match (for example) Cell C3 to Cell C3 in the month before and color Red if the price has increased, Green if the price has decreased and remain white if the price is the same. I want to do so for each of the cells C3:M30.
I have managed to find a formula to match cell C3 to C3 then cell C4 to C4 etc. untill cell C30. This is the formula I used:
=C3>INDIRECT("OKTOBER 2020!C"&ROW())
This works fine for Column C, but I can't find a way to incorporate Columns D:M in this formula. Is there a way to incorporate the conditional formatting rule for Columns D:M in the same formula? Or should I just add this formula to each row with the corresponding row Letter?
Answer:
You can do this with an ARRAYFORMULA.
Formula:
=ARRAYFORMULA(C3:M30>INDIRECT("OKTOBER 2020!"&SUBSTITUTE(ADDRESS(1,COLUMN(),4),"1","")&ROW()))
Rundown of this formula:
Creates an ADDRESS of a cell which has a row of 1, the current column index, using a relative reference.
Substitute the hard-coded row number 1 to extract out the column letter
Construct an indirect reference to the current cell using the extracted column letter, the current ROW(), and appending it to the string OKTOBER 2020!
Check if this cell is greater than the current cell
Run this whole formula on the range C3:M30. This can be expanded to cover additional cells, if necessary.
This formula checks if the price has gone up, for which the conditional formatting should reflect as such. You can also do this for when the price has decreased or stayed the same by changing the initial comparison operator:
Price decrease:
=ARRAYFORMULA(C3:M30<INDIRECT("OKTOBER 2020!"&SUBSTITUTE(ADDRESS(1,COLUMN(),4),"1","")&ROW()))
No price change:
=ARRAYFORMULA(C3:M30=INDIRECT("OKTOBER 2020!"&SUBSTITUTE(ADDRESS(1,COLUMN(),4),"1","")&ROW()))
References:
ARRAYFORMULA - Docs Editors Help
INDIRECT - Docs Editors Help
SUBSTITUTE - Docs Editors Help
ADDRESS - Docs Editors Help
COLUMN - Docs Editors Help
ROW - Docs Editors Help

Google Sheets Conditional Formatting For a Column

I have a spreadsheet that has dates in row 1 and data in the rows below it. I want to highlight the entire column that has a date that is today, or within the last 7 days.
I've been searching and I keep finding examples of how to highlight a row, but not a column.
Please try selecting all cells and: Format - Conditional formatting..., Custom formula is and:
=and(A$1>today()-7,A$1<today()+1)
with highlighting of your choice. Done.
In this case the row is anchored, I agree more usual to anchor ($) the column.

Colour a cell based on the length of time between that date cell and another date cell

This query is in relation to Google Sheets.
If the date in B1 is 10 days older than the date in A1, then B1 is shaded red.
If the date in B1 is within 10 days of the date in A1, then B1 is shaded green.
Does anyone know how I can do this please?
We hope to use this as follows:
Record the date we submit a product.
Record a date to show we have detailed the product as suitable.
(We want this to be within 10 days of us initially submitting the product.)
Therefore we submit a product on the date in A1
We then detail the product as suitable and record this date in B1.
If we have done this within 10 days, B1 should be green. If not, it should be red. This will help us deal with delays.
Does anyone know how I can do this within Google Sheets please?
You have to use Format > Conditional Formatting for the column B, defining the range from the second row:
B2:B1000
You have to set the range this way because the formula is always evaluating in its top left corner first. So you can get the past date from row 1 and formatting the cell in row 2.
You should format your cells with custom formula like:
=DATEDIF(A1,A2,"D")>10
Your B column by default can be green.
You can check my demo sheet for this problem here.
DATEDIF:
https://support.google.com/docs/answer/6055612?hl=en
Conditional Formatting:
https://support.google.com/docs/answer/78413

Resources