WRAPCOLS and WRAPROWS functions to change table array - excel

In EXCEL, I would like to change the array of a two columns table (A1:A91;B1:B91) to a 13 X 7 table as follows, by removing the "Turnover" text and replacing the cells with the turnover quantity.
I would like to use some functions such as WRAPCOLS, CHOOSEROWS and TOROW

You can use this formula:
=LET(d,A1:B26,
dOnly,FILTER(d,INDEX(d,,2)<>"Turnover"),
years,UNIQUE(FILTER(INDEX(d,,1),INDEX(d,,2) = "Turnover")),
months,UNIQUE(INDEX(dOnly,,1)),
HSTACK(VSTACK({""},years),VSTACK(TRANSPOSE(months),WRAPROWS(INDEX(dOnly,,2),ROWS(months)))))

In cell D1 put the following formula:
=LET(rng, A1:B26, colA, INDEX(rng,,1), colB, INDEX(rng,,2),
values, FILTER(colB, colB<>"Turnover"),
codes, FILTER(colA, colB="Turnover"),
months, TEXT(EDATE(1, SEQUENCE(1,12,0)),"mmm"),
matrix, WRAPROWS(values, 12),
VSTACK(HSTACK("",months), HSTACK(codes, matrix))
)
and here is the output:
It is just to select conveniently the information we need from the input data to generate it in the format we want. The months since they are all the same we took: 1, i.e. 1/1/1900 and format it via TEXT as mmm. If you need the months for a given year as dates data type and format in Excel as mmmm. Then you can use one of the following options:
Use the formula: EDATE(x, SEQUENCE(1,12,0)), where x represents any date corresponding to January of a given year or use A2 if it is a date in previous formula.
Use the formula: TOROW(UNIQUE(FILTER(colA, colB<>"Turnover"))).

Related

Excel Formula to Calculate Text within a date range

I am trying to calculate values within a specific date range. The data I want to split between each month and the values: Successful, Incomplete and Failed.
I've tried pivot tables with this data but it doesn't work for me, also lacking pivot table excel experience. Formulas I'm more comfortable with.
I am using the following statement to at least get the total number of a value I add into it;
=COUNTIF('Jan 19'!$C$2:$C$1159,"Value")
Ex. If I put into the value "Successful" I get the total number of successful records.
I am looking into having a formula that I can input a specific month/date range (Jan, Feb, etc) and a value to get a count.
Ex. =Formula ((RangeOfData, "Value") AND (RangeOfData, (FromDate, ToDate))
I expect to the get the total number of a value(s) within a specific date range. If there isn't any data then the results would be blank or 0.
I'd use the formula COUNTIFS() as #cybernetic.nomad pointed in the comments so you can put more conditions on the COUNT:
=+COUNTIFS('Jan 19'!$B$2:$B$1159,">="&F3,'Jan 19'!$B$2:$B$1159,"<"&G3,'Jan 19'!$C$2:$C$1159,H3)
In the formula above I guessed the dates are in the COLUMN B, if not, you need to change it in the formula above.
To do that we should put the range we want to look at in a couple of cells where you would put the date range, in the example above:
F3 is the start date (if you want February of this year should be 1/2/2019).
G3 is the final date (if you want February of this year should be 1/3/2019).
H3 is where you can write "value", "successful" or any other string you are trying to count.

Excel - SUMIF and Weekday

Note: I am putting this question as Excel and Google Docs as they have a ton of overlap for simple questions like this.
I have two columns of data. A date of a purchase and how much that purchase was for.
A B
11/23/2015 $59
12/5/2015 $23.32
1/21/2016 $12.09
1/22/2016 $78.21
1/22/2016 $5.88
2/14/2016 $0.13
... ...
(thousands of rows below this)
I want to SUM the amount of money spent on Mondays, Tuesdays, Wednesdays, etc.
If I use SUMIF, I run into this problem:
=SUMIF(A:A, WEEKDAY(A:A), B:B)
^ WEEKDAY only takes in a single date value.
I do not want a function that I have to drag downwards.
How would I accomplish this?
Try this query function:
=QUERY({A:B},"select dayOfWeek(Col1), sum(Col2) where Col1 is not null group by dayOfWeek(Col1)")
In this formula I used Array {A:B} and notation Col1, Col2... in the formula because now when you add new columns, the formula won't fail.
And the similiar formula, using sumif:
={arrayformula(unique(weekday(A:A))),arrayformula(sumif(week‌​day(A:A),unique(week‌​day(A:A)),B:B))}
In Excel you do it with this Array formula. Array formula needs to be entered with Ctrl-Shift-Enter.
{=SUM(IF(WEEKDAY($A$2:$A$1000,1)=E2,$B$2:$B$1000,0))}
This assumes your day of week in number is E2. The second parameter in Weekday function defines how you number the days of Week. Here I have used 1 which means 1 = Sunday and 7 = Saturday

SUMIFS in Excel with cell reference

I'm trying to sum the values in sheet GLTB column D where the value in column A starts with 2.21 and the value in column E is equal to the date in the cell A1. I tried this formula:
=SUMIFS(GLTB!$D$3:$D$26522,GLTB!$A$3:$A$26522,"2.21*",GLTB!$E$3:$E$26522,GLTB!$A$1)*-1
The problems:
The date in A1 doesn't appear anywhere else on the GLTB sheet, so I should get 0 for a sum, but I don't. I get some number that doesn't correspond to anything I can find.
I can make all the values in column D where column A starts with 2.21 equal to 0 (or any other number) and it has no effect on the result of the formula.
I tried this formula based on answers to other questions:
=SUMIFS(GLTB!$D$3:$D$26522,GLTB!$A$3:$A$26522,"2.21*",GLTB!$E$3:$E$26522,GLTB!"="&$A$1)*-1
This just changes the last criterion reference. However, Excel gives me a formula error response.
Any ideas?
This should get you a little closer:
=SUMIFS(GLTB!$D$3:$D$26522,GLTB!$A$3:$A$26522,">=2/21/16",GLTB!$E$3:$E$26522,GLTB!$A$1)*-1
This assumes that column A contains date values which are formatted as string. If these values are not date values, then please give some example of what cell contents in column A.
Note: I'm not clear on why you're searching for "2.21*" so I used the >= operator. That can be changed, or we could add additional criteria to the SumIfs based on your needs.
Other things to be careful of:
Ensure that column E and cell A1 both contain the same type of data (either date formatted as string, or string data representing dates. If you have inconsistent data types, the equivalence test in your Criteria2 (GLTB!$E$3:$E$26522,GLTB!$A$1) will not return the desired results.
To start with, you should format your data as table. To do this, use "Start > Format as table". This will also give you the option of giving your table a name, e.g. data. Basically this makes performing the following steps easier.
From then on, you don't need to reference with GLTB!$A3:$A26522anymore, but can use data[ColumnA].
I'm assuming you have a column ValueA with something in there that might start with 2.21, then ValueD which you want to sum and DateE which should be equal to a certain date.
The formula you are looking for is not SUMIF, but the much better SUMPRODUCT, as this allows you to check multiple conditions.
The final formula will look like this:
=SUMPRODUCT((data[DateE]=A1)*(LEFT(data[ValueA],4)="2.21")*data[ValueD])
Now what does this do. SUMPRODUCT first builds a product and then sums that up. Let's assume the following values:
A1 = 2016-03-01
DateE = 2016-03-01
ValueA = 2.213454
ValueD = 3
The formula will then do the following:
(2016-03-01=2016-03-01) is 1
("2.21" = "2.21) is 1
3 is 3
1*1*3 = 3
Now if you change the date in A1, the value of your SUMPRODUCT cell should change accordingly.
As a starter I recommend using Tables - it's much easier to read and maintain your data: Insert-->Table.
e.g.
Here I have "Table1", with the Date column formatted as a Short Date.
Name Date Quantity
Alpha 17-Mar-16 1
Beta 15-Feb-16 2
Charlie 11-Mar-16 3
Dog 11-Feb-16 4
Echo 9-Feb-16 4
Foo 6-Jan-16 5
Then in a separate row/cell, you can input a formula to sum the quantity column where the data is from 1st Feb onwards.
Here I've used a different date format, but Excel is fine with it.
Feb Onwards Total: 14 =SUMIFS(Table1[Quantity],Table1[Date],">=01-Feb-16")
Feb Only Total: 10 =SUMIFS(Table1[Quantity],Table1[Date],">=01-Feb-16", Table1[Date],"<29-Feb-16")
Try something like this:
=SUMPRODUCT((INT(GLTB!$E$3:$E$26522)=INT(GLTB!$A$1))*(ROUNDDOWN(GLTB!$A$3:$A$26522,2)=2.21)*(GLTB!$D$3:$D$26522))
If this Returns and error, then one of two things:
your dates are not true dates but text that look like dates.
your have errors in your cells in some of the columns.

Excel convert date to text retaining date layout

I have rows containing every Monday and Sunday in an entire year, (with variations on when a month starts and ends) like so,
11/05/2015 18/05/2015 25/05/2015 01/06/2015 08/06/2015
17/05/2015 24/05/2015 31/05/2015 07/06/2015 14/06/2015
However these are in the date format, and I need them in a text format, but so they still read in the dd/mm/yyyy format, not like 42125.
Further up my document, each column header should read dd/mm/yyyy-dd/mm/yyyy using each of the dates shown in my first example, and I was hoping to achieve this using the formula =A30&"-"&A31 and so on. So the desired outcome should read,
11/05/2015-17/05/2015 18/05/2015-24/05/2015
11/05/2015 18/05/2015
17/05/2015 24/05/2015
However using the =cell&cell formula im left with
42135-42141 42142-42148
11/05/2015 18/05/2015
17/05/2015 24/05/2015
I have to create these headings for 2 years worth of dates, and trying to avoid typing every heading out manually, is there a way to achieve this?
Use the TEXT function which comes with Excel.
Assuming cell A1 has "11/05/2015", use the following formula in cell B1:
B1=TEXT(A1,"dd/mm/yyyy")
This takes care of the first part of your question. For the second part, you can use the CONCATENATE function. Assuming that B1 and B2 contain dates as text, you can join them together using the following formula:
=CONCATENATE(B1, "-", B2)
Try converting those values to text before concatenating:
=TEXT(A1,"dd/mm/yyyy")&"-"&TEXT(A2,"dd/mm/yyyy")
You need to break them down like so:
=DAY(A3)&"/"&MONTH(A3)&"/"&YEAR(A3)&"-"&DAY(A4)&"/"&MONTH(A4)&"/"&YEAR(A4)
I am assuming here your data start from cell A3
Assuming headings in row 1 and dates in rows 3 and 4 this will work:
=TEXT(A3,"dd/mm/yyyy")&TEXT(A4," - dd/mm/yyyy")
without having to concatenate " - "

Microsoft Excel Array Formula with dates

I need the following array for a Date type:
=IF(OR(A2:C2="Mar 12"),1,0)
Sample Data
https://docs.google.com/spreadsheet/ccc?key=0AhoDU0OTM87sdHR3RGw3NTJacEV1OEt5OWZTWTBYUFE&usp=sharing
Looking at the sample data, in Column E I want an array formula that would look into columns B to D and search for results that contain 'May 12' and display true or false (1 or 0) in column E.
I think this will meet your needs - type in D2:
=IF(SUM((MONTH(A2:C2)=5)*(YEAR(A2:C2)=2013))>0,1,0)
but press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {} brackets around it (but do NOT type them manually!).
Specify month and year as you wish)
I think this is what you're looking for (noticed the date format was dd/mm/yyyy so I adjusted):
=IF(COUNTIF(A1:C1,"12/5/2013")>0,TRUE,FALSE)
Edit:
For just month and day:
=IF(SUMPRODUCT((MONTH(A1:C1)=5)*(DAY(A1:C1)=12))>0,TRUE,FALSE)
Month and year:
=IF(SUMPRODUCT((MONTH(A1:C1)=5)*(YEAR(A1:C1)=2012))>0,TRUE,FALSE)

Resources