Excel countif comma separated criter - excel

I have an excel spreadsheet with a project column and columns for each month of the year. On a different tab on the same spreadsheet, tab name = JIRA. For example:
Main Tab:
Project(Column L) hours
P1
P2
JIRA tab
Project (col B) Jan hours (Col J) FEB hours (Col K)<br>
P1 14 10<br>
P2 15 10<br>
P3 5 15<br>
P4 32 5<br>
P5 20 22<br>
P6 25 15<br>
If I use the following formula in the hours column of the main tab in the Feb column, I can get the hours to populated correctly:
=SUMIF(JIRA!$B:$B,L4,JIRA!$J:$J)<br>
My Problem:
I want to put multiple project number on the same column on the main tab separated by a comma:
Main Tab:
Project(Column L) hours<br>
P1<br>
P2<br>
P1,P2<br>
P3,P4,P5<br>
How do I get the sumif formula to recognize multiple project names and search for each project summing the total? Based on the above, after plugging in the correct formula, I want to see:
Main Tab:
Project(Column L) Jan hours FEb hours<br>
P1<br> 14 10
P2<br> 15 10
P1,P2<br> 29 20
P3,P4,P5<br> 57 42
any help would be appreciated.
Thanks,
frank

You can use this formula:
=SUMPRODUCT(ISNUMBER(FIND($A$2:$A$10&",";D2&","))*$B$2:$B$10)
In my example names(P1,P2...etc) are in A2:A10, B2:B10 contains the values to sum and D2 is the names your looking for.
Depending on your Regional Settings you may need to replace ";" by ","

Related

In spreadsheet (Excel or Google Sheets), how to find the sum of multiple values with multiple rows of column headers criteria?

as in the above picture, I need to sum all the values within the table C8:V22 which match
the first three characters of column B(orange),
row 5 for the number(blue),
row 6 for the first character(green),
row 7 for the first three characters(yellow)
The desire result would be the sum of the number in red, which is 10001 + 10081 + 10161 + 10221 = 40464
I tried many different ways to write the formula, one of that is:
=INDEX($B$5:$V$22,
MATCH($D$26,LEFT($B$5:$B$90,3),0),
MATCH(($F$26=$5:$5) * ($G$26=LEFT($6:$6, 1)) * (H26=LEFT($7:$7,3)), 0))
and pressed Ctrl+Shift+Enter to make it as an array formula, but couldn't figure out where is the error.
Anyone could help on this? Thank you!
Edit: The following is a simplify table for easy reference:
1
2
3
a1
a2
b1
abc1
abdf2
abc2
111a
11
12
13
222a
14
15
16
111b
17
18
19
555a
20
21
22
333d
23
24
25
111a
26
27
28
in this case, the match values are 11 + 17 + 26 = 54
I also tried using combinations of functions such as SUMIFS, SUMPRODUCT, search, e.t.c. but still not able figure out the solution.
In your sheet:
=SUMPRODUCT((LEFT(B8:B22,3)=C26&"")*(C5:V5=E26)*(LEFT(C6:V6,1)=F26&"")*(LEFT(C7:V7,3)=G26&"")*C8:V22)
simply retrieve the sum using your parameters and converting in string to match exactly.
If you have Excel 365 you can use this formula:
=LET(data,C8:V22,
ruleColumnB,LEFT(B8:B22,LEN(D26))=TEXT(D26,"0"),
ruleRow5,C5:V5=F26,
ruleRow6, LEFT(C6:V6,1)=G26,
ruleRow7, LEFT(C7:V7,3) =H26,
SUMPRODUCT(data*ruleColumnB*ruleRow5*ruleRow6*ruleRow7)
)
)
Using LET makes the formula more readable - esp. if you name the rules according to your special context.
If you don't have Excel 365 you have to replace the single parameters within SUMPRODUCT with each range/formula

Excel count days per month between two dates using both months and years

I would like to know how to calculate days of each month between two dates:
A
B
C
D
E
F
G
1
From
To
01/12/20
01/01/21
01/02/21
01/03/21
01/04/21
:--
:---------:
:-----:
:---------:
:--------:
:--------:
:--------:
:-------:
2
15/12/20
12/3/21
17
31
28
12
0
I have tried using a formula I found elsewhere on this website but it only picks up the relevant months from the column headers in row 1. I need it to pick up the years as well. I wonder if anyone is able to alter this formula to include years as well:
=SUMPRODUCT(--(MONTH(ROW(INDIRECT($A2 & ":" & IF($B2="",TODAY(),$B2))))=MONTH(C1)))
Note: Row 1 Dates are dates and not text.
Charles
Try:
C2: =MAX(MIN(EOMONTH(C$1,0),$B2)-MAX(C$1,$A2)+1,0)
and fill across (and down) as needed.

Excel automatically charting for concrete range of data

Excel masters, I need help about charting in excel. I have a table with data ("WEEK number", "date of start", "some data") and chart! the problem is: I need when I add new week data the chart should automatically update but I need to see only 53 weeks. For example: if I add week 30 I need to see data on the chart from week 30 (2018) to week 30 (2019)
Thank you for your help in advance
Week # Start Date Data
20 05-13-2018 21,866
21 05-20-2018 20,317
22 05-27-2018 18,078
23 06-03-2018 19,254
24 06-10-2018 17,990
25 06-17-2018 19,589
26 06-24-2018 22,346
27 07-01-2018 18,985
28 07-08-2018 18,482
29 07-15-2018 17,493
30 07-22-2018 21,217
31 07-29-2018 16,205
32 08-05-2018 16,534
33 08-12-2018 16,694
34 08-19-2018 18,190
35 08-26-2018 20,559
36 09-02-2018 24,503
37 09-09-2018 26,074
38 09-16-2018 24,092
39 09-23-2018 33,828
40 09-30-2018 28,979
41 10-07-2018 28,493
42 10-14-2018 30,634
43 10-21-2018 29,473
44 10-28-2018 28,202
45 11-04-2018 30,088
46 11-11-2018 36,070
47 11-18-2018 36,689
48 11-25-2018 35,509
49 12-02-2018 27,794
50 12-09-2018 27,802
51 12-16-2018 16,521
52 12-23-2018 13,786
1 12-31-2018 18,271
2 01-07-2019 27,336
3 01-14-2019 29,837
4 01-21-2019 31,464
5 01-28-2019 31,395
6 02-04-2019 31,383
7 02-11-2019 28,152
8 02-18-2019 30,795
9 02-25-2019 25,183
10 03-04-2019 28,344
11 03-11-2019 38,064
12 03-18-2019 36,815
13 03-25-2019 36,741
14 04-01-2019 35,849
15 04-08-2019 35,199
16 04-15-2019 28,407
17 04-22-2019 16,427
18 04-29-2019 29,678
19 05-06-2019 28,270
20 05-13-2019 24,046
21 05-20-2019 21,191
22 05-27-2019 21,480
23 06-03-2019 23,919
24 06-10-2019 20,532
25 06-17-2019 20,575
26 06-24-2019 19,111
27 07-01-2019 19,279
28 07-08-2019 22,265
29 07-15-2019 5,979
You can use defined names to automatically update a chart range in Excel.
You can refer to any array/range by a name in excel. There are formulas to find the specific array/range and we call them Array Formulas. One of the most common array formula is OFFSET. If you are not familiar with this formula, please google some tutorials online before continue.
In your example, let's presume Week # is in Column A, Start Date is in Column B, and Data is in Column C, and the name of the worksheet is SheetName.
In order to dynamically look up a 53-Week range in Column A, B and C using OFFSET formula, you need to find the starting point (i.e. the cell in each column corresponds to the first week of the 53-week range) .
For instance, if your latest Week # is Week #29 in Cell A63, the starting point would be Week #29 in Cell A11. One way of finding the latest week # is to find the corresponding maximum/latest date in the Start Date column, and use MATCH formula to find the row number. Such logic is translated into the following formulas:
Start Point in Column A (the Week # column) ="A"&MATCH(MAX(B:B),B:B,0)-52
Start Point in Column B (the Start Date column) ="B"&MATCH(MAX(B:B),B:B,0)-52
Start Point in Column C (the Data column) ="C"&MATCH(MAX(B:B),B:B,0)-52
Then you can find the 53-Week range in each column by referencing the relevant starting point in the OFFSET formula. Please note you need to press CSE Ctrl+Shift+Enter upon finishing entering each array formula to make it work.
For Column A (the Week # column) =OFFSET(INDIRECT("SheetName!A"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
For Column B (the Start Date column) =OFFSET(INDIRECT("SheetName!B"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
For Column C (the Data column) =OFFSET(INDIRECT("SheetName!C"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
The next step is to create three names for the above ranges. Press Ctrl+F3 to open the Name Manager in excel, and manually create the names and copy and paste the above formulas in the 'Refers to:' field.
Then you can create a chart from the existing data, and replace the hard-coded series values with the range names to make it dynamic as shown below:
Click anywhere within the chart, then you will see the Chart Design tab shown on top of the the ribbon of your excel. Go to Select Data and Edit the Data and Date value as shown below:
I have created a sample bar chart below showing the data for the most recent 53 weeks. Please note I have added 5 weeks' of new data to test the result, and I have put the Week # as the data label for the bar chart instead of the actual dollar value.
Lastly, you can refer to the following article for more clarifications.
How to use defined names to automatically update a chart range in Excel

Lookup "Text" Variable between dates

Let me preface this question with: The data that I was provided is not in the most logical order and the work involved in scrubbing to a more uniform it would be time consuming.
I am compiling a sales sheet to collect an overall yearly view of each product's revenue. I am currently attempting to search for the product name within the sheets required within a main sheet (all within the same workbook).
See sample output below:
Year
2014 Jan Feb Mar ... Nov Dec
Product 1
Product 2
Product 3
2015 Jan Feb Mar ... Nov Dec
Product 1
Product 2
Product 3
Sample Input
... F ... N ... T ...
... Date ... Product ... Amount ...
------------------------------------------------------
10/03/15 ... Prod. 1 ... $1000.00 ...
04/05/15 ... Prod. 3 ... $3000.00 ...
02/09/15 ... Prod. 1 ... $2000.00 ...
I would like to break it down based on month and product which is where I am running into issues. Currently I am (attempting) using:
=SUMIFS('2015'!R:R,'2015'!F:F,"Product 1",">=1/1/2015",'2015'!F:F,"<=1/31/2015")
Any help provided would be greatly appreciated!
SUMIFS() is the best way to go. But one can make the criteria more dynamic so the formula can be copied from cell to cell instead of having the values "hard coded" in the formula.
To do such ensure that your month row is Actual dates that have a number format of mmm instead of text.
As you can see the Jan cell is actually 1/1/2015. We could have made this a little more dynamic also. Instead of the year being hard coded, since I put the year in A2, I could have used this formula:
=DATE($A$2,Column(A:A),1)
And drag/copied across. This would have put the first day of each month.
Again do a custom format of mmm
Then the formula would be:
=SUMIFS('2015'!$T:$T,'2015'!$N:$N,$A3,'2015'!$F:$F,">=" & EOMONTH(B$2,-1)+1,'2015'!$F:$F,"<=" & EOMONTH(B$2,0))
This formula then is dragged/copied across and down.

How to calculate workdays and compensation for given period based on Employee's monthly salary?

I have only three editable fields:
salary = 15,000
start date = 18 Jul 2014
end date = 12 Oct 2014
With these fields, I need to calculate the total salary I need to pay. Payment is on a monthly basis:
(JULY = 15,000 / 31 * 14) +
(AUG = 15,000 / 31 * 31) +
(SEPT = 15,000 / 30 * 30) +
(OCT = 15,000 / 30 * 12).
I can get total days based on both dates (ie 87 days, =DAYS($enddate,$startdate)+1) ) but I need to split the days according to the months.
What formula do I need automatically to get the amount, because each person will have different salary and different dates?
You can use Excel VBA custom Function to solve your problem:
1). First, you should populate Excel Worksheet with data structure reflecting Employees Name, Monthly Salary, StartDate and EndDate, like in the following sample:
Employee M.Salary Start Date EndDate
John $15,000.00 7/18/2014 10/12/2014
Ann $20,000.00 7/19/2014 10/13/2014
Peter $16,000.00 7/20/2014 10/14/2014
Jeff $25,000.00 7/21/2014 10/15/2014
2). The DAYS in date range can be simply found by subtraction (EndDate-StartDate), because the underlying data type in integer
3). For general solution to the problem (Calculate the compensation for any arbitrary period and monthly salary) you will need to create custom VBA formula and use it in a separate column for each Employee. Refer to this article for explanation: Create a custom worksheet function in Excel VBA
4). Pertinent to your particular case with fixed date rage, the simplified solution based on the Excel Worksheet formulas (no VBA) is described below:
Employee MoSalary Start End Days FullMo FirstMo LastMo Total
John $15,000.00 7/18/2014 10/12/2014 87 30000.00 $6,774.19 $6,000.00 $42,774.19
Ann $20,000.00 7/18/2014 10/12/2014 87 40000.00 $9,032.26 $8,000.00 $57,032.26
Peter $16,000.00 7/18/2014 10/12/2014 87 32000.00 $7,225.81 $6,400.00 $45,625.81
Jeff $25,000.00 7/18/2014 10/12/2014 87 50000.00 $11,290.32 $10,000.00 $71,290.32
4a). In column E starting with row 2 add formula for DAYS : =(D2-C2)+1 and extend it for entire range
4b). In column F starting with row 2 add formula for whole months : =2*B2 and extend it for entire range
4c). In column G starting with row 2 add formula for the first month : =14*B2/31 and extend it for entire range
4d). In column H starting with row 2 add formula for last month : =12*B2/30 and extend it for entire range
4e). In column I starting with row 2 add formula for total compensation : =SUM(F2:H2) and extend it for entire range
Hope this will help. Best regards,
I have split this out because I am not entirely sure what you require and you may be able to assemble the pieces in a way that better suits you:
Assuming your data is in A1:A3, put 1/7/14 in C1, 1/8/14 in D1, 1/9/14 in E1 and 1/10/14 in F1.
To count the number of applicable days by month, in C2 enter:
=IF(MONTH($A2)=MONTH(C1),EOMONTH(C1,0)-$A2+1,IF(MONTH($A3)=MONTH(C1),DAY($A3),EOMONTH(C1,0)-EOMONTH(C1,-1)))
To compute the salary for the month by computing the daily rate for the applicable month and multiplying that by the number of days from above, in C3 enter:
=$A1*C2/(DAYS(EOMONTH(C1,0),C1)+1)
Format C2:C3 to suit and copy across to F2:F3.

Resources