how to calculate values using COUNTIF - excel

I have two sheets in my Excel file: Sheet1 and Sheet2.
In Sheet2 i have data with columns Severity and LodgedDate. In Severity there are multiple values like
sev-1
sev-2
sev-3
sev-4
In Sheet1 I want to calculate the no. of occurrences for sev-1, sev-2, sev-3, sev-4 for today, this month, this financial quarter, last quarter, older than last quarter.
Can anyone help?
Like
=COUNTIF(shee2, C2:C,"sev-1" , "Today").

Assuming the date is in column B, try along the lines of
=countifs(Sheet2!C:C,"sev-1",Sheet2!B:B,today())
For the current month
=COUNTIFS(Sheet2!C:C,"sev-1",Sheet2!B:B,">=1-Mar-2017",Sheet2!B:B,"<31-Mar-2017")
So, for a time frame enter the first and the last day of the time frame into two conditions.
You may want to use a pivot table instead of countifs formulas. It is a lot faster and won't require you to type out all the possibilities.

Related

Adding values to different cells depending on conditions - Excel

I am not very good with excel formulas, and I would need some help with a process I want to implement:
Simplifying things, I have an excel sheet (sheet n°1) with rows like this:
Company name | Price | Date
On other excel sheet (sheet n°2) I have one row for every company, and in each column there are all 12 months. I would need a formula so every time I add a row in the first sheet, the price I add is automatically added to the corresponding company row and in the corresponding month (based on the date) on sheet 2
I am really lost here, I know how to apply simple formulas, but not this, is there a way to add each value to a different cell depending on some conditions?
I forgot to add, that I would need to sum this values in sheet 2, so every time I add a new value, it is summed to the actual value of the corresponding cell.
I hope my english is not to bad, and thank you in advance!! :)
Use SUMIFS()
=SUMIFS($Q:$Q,$P:$P,$A2,$R:$R,">="&EOMONTH(B$1,-1)+1,$R:$R,"<"&EOMONTH(B$1,0)+1)
One caveat to this the month headers must be an actual date in the month desired. This can be formatted any way you want to display. My cells all contain the 1st of each month as their true dates.

Comparing Month with date(MM/DD/YR)

Is it possible to compare a month number with a date(MM/DD/YR) in Excel/Google Sheets?
For example, according to the screenshot, I just want to calculate the weekly time only in September and not August. I want it to be general so whatever month I choose, it will only calculate the hours for that month and not other months that is displayed on the table. I think the way to approach the problem is writing an if statement where if the DATE column starts with "9", then it will only calculate that row, and ignore the other rows that is not a 9.
I am just not sure if we can compare multiple cells to see if it matches with a certain month.
all you need is:
=SUM(FILTER(B1:B7, MONTH(A1:A7)=8))
You could use SUMIFS in both Excel or Google Sheets:
=SUMIFS(E2:E8,A2:A8,">="&F10,A2:A8,"<="&EOMONTH(F10,0))
Adjust ranges (and make them absolute if need be)

Excel - Take Average of Monthly Data

I have a historical data set for commodity pricing. Throughout the data set, the data starts inputting prices on specific days, rather than the average of the entire month. In order to keep the flow of having only the average pricing for the months.
In the best case scenario, I would use an Averageif function, however, the data for each month doesn't display a consistent amount of days.
How can I automate this the process: If the month is the same as the previous row and different than the next row, calculate the average of the ^ rows until you hit the next month.
Here's a simple display of what I mean:
]1
You can use a pivot table to get the output you want. It will also be neatly organized instead of having your averages mixed in with a mostly blank column. Photo below shows the set-up/output of a pivot table generated with random data.
For a solution without pivot tables, you can use the following formula :
=AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0))
The above example is from cell C1, and can be copied down the entire list. The dates are in $A$1:$A$30 and the values in $B$1:$B$30. The first conditions test on the first day of the month (calculated as A1-DAY(A1)+1),and the second condition as last day of the month (calculated as EOMONTH(A1;0)
This will obviously put the average value of the month on each row, but will also work if your data is not sorted on date. If this is the case, and you only want to display one number per month in the column (as in your own example), you can add an additional IF statement wrapped around the formula:
=IF(EOMONTH(A2;0)=EOMONTH(A1;0);"";AVERAGEIFS($B$1:$B$30;$A$1:$A$30;">="&(A1-DAY(A1)+1);$A$1:$A$30;"<="&EOMONTH(A1;0)))
So it will display empty in all cells, except where the month changes.

Is it possible to output the values of a column in excel based on a dynamic date value?

In the following table I have weeks as columns, employees as rows and the values are the amount of holiday days per employee per week taken.
I want to create a separate table as a dashboard where the output will change depending on the date I input into the date selector. In the example below, I have chosen the 2/11/2015 as my week and I would like to only see the corresponding values for that week in the output table. How do I go about doing this?
Try this in B5:
=Index($B$34:$F$48,MATCH($A5,$A$34:$A$48,0),MATCH($C$1,$B$33:$F$33,0))
Then copy down.
Change the F column References in the formula to get the extent of you columns of data.
As a Note: If you are in a country that use ; as the delimiter between criteria instead of , here is the formula with those delimiters:
=Index($B$34:$F$48;MATCH($A5;$A$34:$A$48;0);MATCH($C$1;$B$33:$F$33;0))

Excel - add rows

Hi I have a sheet of data that is reported by week. For my problem I can only use months. The columns that I have are Month, Value, Week. Weeks are in order, but months repeat: weeks 1 - 3 are in Month 1, weeks 4-7 are in Month 2, etc. In this sheet I need to sum the values by month. How do I accomplish this?
Thank you in advance.
It really depends on how you want the data. Do you just want a value in a cell with the data? Then this formula would work for the following data:
=SUMIF(A:A, A2, B:B)
If you want this in a more aggregated format, I would use a pivot table referencing this data and making sure to add the Month in as the ROWS and Value as the VALUES (defaults to sum) as pictured:

Resources