Reverse array list dynamically - excel

I have an array list in column A (starting in A2) using:
{=IFERROR(INDEX(MonthSpend,MATCH(0,COUNTIF($A$1,A1,MonthSpend),0)),""}`
Where MonthSpend is a named range from a table on a separate sheet.
I have copied the formula down to A300, but inserted blanks in a number of rows.
From the picture you will see that I have each month showing up only on every 6th row. The formula in A8 is:
{=IFERROR(INDEX(MonthSpend,MATCH(0,COUNTIF($A$1:A2,MonthSpend),0)),"")}
and in A3:A7 there is nothing).
I named this range in column A MonthAcc.
In column B (starting in B2), I tried using:
=IF(MonthAcc>10,INDEX(MonthAcc,COUNTA(MonthAcc)+ROW(MonthAcc)-ROW(),1),"")
to reverse this list.
This didn't work because the reversal function in B2 references a row near the bottom of the MonthAcc list, which is blank.
I'm trying to get it so that in B2 (in the picture below) it would have January 1, 2020 and then in B8 it would have December 1, 2019 and then in B14 it would have November 1, 2019 and so on.
The list MonthSpend is dynamic so can be totally different lengths.
How do I reverse my dates but keep it starting at the top and only every 6th row?
In the second picture you will see a column called Month. It uses the function =IF(E3="","",DATE(YEAR(C3),MONTH(C3),1)) starting in F3 and copied down the entire table. This is the named range MonthSpend. It is dynamic in that for a different project, you could have dates ranging from April 2017 to January 2020 etc. So the months that show up in the Month column, are what I want in my new reversed list, spaced 6 rows apart.

With the column Week ending you can use the following formula:
=IF((MOD(ROW()+4,6)=0),LOOKUP(2,1/(COUNTIF(C$1:$C1,$A$2:$A$25-DAY($A$2:$A$25)+1)=0),$A$2:$A$25-DAY($A$2:$A$25)+1),"")
It returns distinct dates from list converted to first day of month (you can also convert to other formats using the appropriate functions.) in reverse order every sixth row. Dates must be sorted in source column in ascending order. BUT! For empty cells it returns first day of XX century, so I enter that date manually to C2, if it bothers, it can be hidden

Related

Modify and transpose large dataset in Excel

I am trying to convert a database that consists of hourly data on annual basis from 00:00 (hour) 01 (month) 2015 (year) to 00:00, 01-12-2021.
Default format of the table:
In the default format, one column contains both hour and date and the second contains the value. There are more than 60000 rows.
What I expect:
In the expected format, the first column contains only the date while the first row contains the hours. I want to write a formula (maybe with transpose?) that transfers for each date and hour the value to the new cell.
For example, for 02-01-2021, at 01:00, the corresponding value is 52.42. To do this I click "TRANSPOSE(AD27:AD50)" and the row is filled. AD is the column location of the default format.
Unfortunately when I click with my cursor to the 3rd row (where 02-01-2021 is located) and drop it down to pass it to the next row, Excel does not recognize the pattern.
While Excel should start from the last selected column and transpose the next 23 cells (AD51:AD74) it goes like this (AD28:AD51).
In the third picture you see:
With the red pen: The old format. Date and time are in the same cell (column AC).
With the black pen: Date has been split from time. Date is in a column A while time is in row 1.
With the blue pen: The cells I want to fill by transferring the data listed in the table (pinpointed by the red pen).
In version 2202, you should have the more recent functions, so a simple method would be:
select some cell in your date/time table
Home/Format as table
Then:
E2: Enter a list of the dates only from your table.
*This can be done in various ways*
F1: Enter a list of the hours from left to right (or use the `SEQUENCE` function to generate them)
F2: =TRANSPOSE(FILTER(Table1[Value], DATEVALUE(TEXT(Table1[DateTime],"m/d/yyy"))=$E2,"")) and fill down as far as needed
The results will spill right.

Sum based on dates on multiple column in Excel

1 st column date and 2nd column amount 3rd column date and 4th column amount .. is going on.
I want to sum based on date, If date between 2019 to 2020, i need sum the amount.
I was able to get the function SUMPRODUCT to work, assuming I understand what you want to do. (I think you want a billings total for each year, is that right?)
See this ExcelJet article on SUMPRODUCT.
There's probably a way to make this even shorter, but here's one solution:
See screen clip (I'm not allowed to post images yet.)
Formula for cell C6: =SUMPRODUCT(--(YEAR(B$3:B$4)=2019),C$3:C$4)
Copy that into cells E6, G6, I6, K6, and M6. The column references will adjust.
This will give you the 2019 totals for each of the 6 periods in row 6.
Formula for cell C7: =SUMPRODUCT(--(YEAR(B$3:B$4)=2020),C$3:C$4)
Copy that into cells E7, G7, I7, K7, and M7. The column references will adjust.
This will give you the 2020 totals for each of the 6 periods in row 7.
Formula for cell N6: =SUM(B6:M6). This is the 2019 total (the sum of row 6).
Formula for cell N7: =SUM(B7:M7). This is the 2020 total (the sum of row 7).

List adjacent cell values if date belongs to month 1, 2, 3 (jan, feb, mar...) etc

I have a list of dates in column B and a list of working hours in column C. I would like to get all the values (hours) listed in column D from column C if adjacent cell value in column B belongs to Month 1 (January).
Then I would like to drag the formula downwards and to the right so that column E = February, columnF = March etc.
The answer to column D should be a list with all the hours from column C that are in January in columnB and by dragging the formula down and to the right to get the formula working for all the other Months as well.
Note that the dates might be in disorder!
I've tried with INDEX MATCH but I can't get my different formulas to work with the MONTH() function. I've tried to find an answer to the problem for many hours now without success. All help appreciated.
Double check that your dates are being read correctly by first putting =MONTH(A2) and ensuring the appropriate value (1 - 12) comes out. Once you have verified that the following should do what you want.
In column D: =IF(MONTH($C2)=1,$B2,"") This formula can be dragged to the right first and replace 1 with 2 - 12 as appropriate for the month. Then copy them down.

I want to have a cell to store different values for different months in excel (same cell but 12 values for 12 months)

Is it possible to have a cell which contains a different value for each month? the value will be entered manually for each month(for example for Jan its 2, for Feb its 5 and.... in the same cell) and I will scroll from one month to another.
You can use VLOOKUP, but you will need a data array for the values.
The Formula for D2 is =VLOOKUP(D1,A1:B12,2,FALSE). Your manually entered value goes into D1.

Excel: Derive Table column name with formula

I have an Excel table called weather_data and it has a column for each month, e.g. "Jan", "Feb", etc.
In another sheet, I have one column with various dates listed and in a second column I want to use a formula to extract data from weather_data. Right now this second table looks like this:
Date Avg_Temp
Jun
Jul
Aug
E.g. if I want to fill in the first entry under Avg_Temp using data from weather_data, which again has a column for each month, I could manually enter =AVERAGE(weather_data[Jun]). However, I was hoping I could make the column reference (Jun in this case) formula driven from the Date column, so I could do something like =AVERAGE(weather_data[A2]) and copy it down.
Is this possible?
Assuming your weather_table starts with January in column 1 and has December in column 12, you can do a formula like this in B2 and copy down:
=AVERAGE(INDEX(weather_data,0,MONTH("1/"&A2)))
This has two interesting parts. The 0 in the row argument of the INDEX formula means to select the entire column. And munging "1/" with the month text in column 1 converts it to a date that can be read by the MONTH function, which then returns the month's number. This is used as the column argument of the INDEX function.
EDIT: Here's one that matches the three-letter month abbreviation in column A of your summary sheet to those in the table headers. This removes the requirement that the table contain only ordered months:
=AVERAGE(INDEX(weather_data,0,MATCH(A2,weather_data[#Headers],0)))
If you wanted to take it a step further and match on just a part of the table header, I wrote a post about that.

Resources