How to sum values based on two criterias - excel
I'm trying to sum values based on two criteria: category and month (Renew).
I want to sum categories by renew month.
So, for things renewed in March, sum separately by category, but what is monthly and have the same category, must be summed too.
Example table
For example:
I have Softwares / Apps / Sites category that have different renew dates (March, April, May, June, September and also monthly).
So, I need to separate and sum values by month, but what are "monthly" have to be summed on all months.
Like this:
Softwares / Apps / Sites category
march: 26,50
april: 24,90
may: 30,60
june: 64
september: 24,90
Hope I made it clear...
I'm going crazy with that... please, help me...
For March:
=SUMPRODUCT(B2:B1000*(C2:C1000="Softwares / Apps / Sites")*(((E2:E1000="Monthly")+(E2:E1000="March"))>0))
Categories and month can be refer to cell. In the picture I can't see column, change them with real layout.
My table data is this:
Description,Price,Category,Period,Renew,Day
Netflix.Com,9,Streaming,Monthly,Monthly,5
Disney Plus,11,Streaming,Monthly,Monthly,5
Amazonprime,8,Streaming,Monthly,Monthly,5
Youtube,8,Softwares/Apps/Sites,Monthly,Monthly,5
Spotify,6,Softwares/Apps/Sites,Monthly,Monthly,5
Google,15,Work,Monthly,Monthly,5
Bank Fees,5,Bank Taxes,Monthly,Monthly,5
Internet,20,Streaming,Monthly,Monthly,5
Healthcare,20,Health,Monthly,Monthly,5
Smart Fit,35,Academy,Annual,June,10
Cellphone Plan,20,Work,Annual,June,10
Backup sw,12.5,Softwares/Apps/Sites,Annual,March,20
Office 365,50,Softwares/Apps/Sites,Annual,June,15
Truecaller,10.9,Softwares/Apps/Sites,Annual,September,10
Kasperksy,10.9,Softwares/Apps/Sites,Annual,April,10
Canva,5.7,Work,Annual,May,15
Kasperksy,10.9,Softwares/Apps/Sites,Annual,May,15
Canva,5.7,Work,Annual,May,5
(To make it easier to answer your questions, please export the data as CSV, then use four leading spaces to format the data in your question - it saves me five minutes typing in the data, and potentially making errors).
The command to use is SUMIFS. The syntax is:
SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)
So, if the entire table is located between A1 and F19, I could do this:
=SUMIFS($B$1:$B$19, $C$1:$C$19,"Softwares/Apps/Sites",$D$1:$D$19,"Monthly")
With my data, a total of 14.
Related
weighted average with sumproduct and offset
I would like to do the following: Calculate a weighted average based on the scenario shown in the sample screenshot. The question I would like to anser is: What is the total amount of sales generated by employee A and employee B, respectively, in a given period (here: in 2021). Screenshot: My Idea was to use a sumproduct formula which selects first all items with reference to employee A and, secondly, all sales of a given product. I use the ISNUMBER(FIND()) construct as wildcard (e.g. with *) does not work with SUMPRODUCT() as far as I know. However, this formula does not work properly. Any suggestions? =SUMPRODUCT(--(Table1[item]=$J46);Table1[2021];--(ISNUMBER(FIND("Sale";TabLe1[item])));Table1[2021])
Office 365 required: =SUMPRODUCT(FILTER(Table1[2021],LEFT(Table1[item],4)="sale"),FILTER(Table1[2021],Table1[item]=$J46)) For older Excel version you could use: =SUMPRODUCT((Table1[2021])*--(Table1[item]=J49),. (OFFSET(Table1[2021],1-MATCH(J49,Table1[item],0),,))* --(LEFT(OFFSET(Table1[item],1-MATCH(J49,Table1[item],0),,),4)="sale")) This is provided that each employee is offset the same way for each sale product.
Get sum of cells containing "Vacation" except when related date matches certain day & month
oversimplified i have two columns: Date and Text; I want to check my current amount of vacation days based on the first date in row 2, so i came up with the following formula: ="Available vacation days: "&YEARFRAC(A2;TODAY())*12*(25/12) I calculate the fraction of the year based on the first date and todays date, multiply it by 12 to get months and multiply it again by the total amount of vacation days in my contract per month. Now i got another formula to collect me all cells in column B containing "Vacation", pretty straight forward: =COUNTIF(B:B;"Vacation") Now the interesting part - i got the formula who gives me a boolean if a datetime matches the 24th or 31st of december: =AND(OR(DAY(A53)=24;DAY(A53)=31);MONTH(A53)=12) I want to count vacation days happening on a 24th or 31st of december as a half-vacation day (0.5), and otherwise fully (as a 1). Then i want to combine my first statement with this result and subtract the used vacation days. I read about VLOOKUP and XLOOKUP but am unsure if this fits this purpose. I want to avoid having an extra column with my boolean returns and rather have this one cell giving me all the information combined.
Without introducing another column, and using DAY and MONTH It's nearly impossible, and just unnecessarily so... Please reconsider this, what will happen if you want to add 4th of July as a holiday? Your formula =AND(OR(DAY(A53)=24;DAY(A53)=31);MONTH(A53)=12) only works for 1 row at a time. So, we can't ever use it with a list, because you will get the whole list as a result every single time. You can't divide them into smaller lists and join them together, there is no such functionality without VBA. In the future, do not set arbitrary constraints like "no additional columns", you can hide them if you don't like them. And if you don't need them, remove unnecessary rows like non-vacation rows. They are irrelevant, so why not separate the two. Just to prove my point, here's the solution you wanted: Solution =COUNTIFS(B2:B9;"Vacation") - (COUNT(IFERROR(FILTER(FILTER(FILTER(A2:A9;B2:B9="Vacation");MONTH(FILTER(A2:A9;B2:B9="Vacation"))=12);DAY(FILTER(FILTER(A2:A9;B2:B9="Vacation");MONTH(FILTER(A2:A9;B2:B9="Vacation"))=12))=31);0))+(COUNT(IFERROR(FILTER(FILTER(FILTER(A2:A9;B2:B9="Vacation");MONTH(FILTER(A2:A9;B2:B9="Vacation"))=12);DAY(FILTER(FILTER(A2:A9;B2:B9="Vacation");MONTH(FILTER(A2:A9;B2:B9="Vacation"))=12))=24);0))))*0,5 It works, but it's a pain to read, use and maintain. A2:A9 refers to the dates column B2:B9 refers to the text column So in the future, the last thing you want to do is set arbitrary constraints. Furthermore, why use functions like MONTH and DAY when we can just read the text? That way you could even create a table of holidays to search for instead. That will be no fun task with this setup. (Oh, and if it's because of the year, just strip it away from the text when you want to know only the month and day. Best of luck!
Determining how many entries were present on each day for a constantly shifting daily dataset
I have searched a lot for a solution to this, but have found nothing. Maybe that's because it's a little hard to describe, or at least, I'm having trouble describing it for a search engine. I have two columns of dates, the first column is the date a purchase order was received to be inspected, the second is the date that purchase order was accepted or rejected. What I would like is a graph with dates on the X-axis, and then the number of purchase orders in the queue on that day on the Y-axis. Some purchase orders are completed that day, so they would still be counted, but they might not get addressed for days or weeks, so they would be counted on all those days until they were addressed. I've been trying to do this with a formula, but am stumped. I feel like I might need to use multiple formulas, or go over to VBA, but my VBA is a little limited. Edit: Here is a sample dataset. Date In Date Out 9/1/18 9/1/18 9/1/18 9/1/18 9/1/18 9/2/18 9/1/18 9/3/18 9/2/18 9/2/18 9/2/18 9/4/18 So, it would be 4 for 9/1/18, 4 for 9/2/18, 2 for 9/3/18, and 1 for 9/4/18. I have tried using COUNTIFS, but I don't know how to check between the two columns for the "between" dates.
If your data is in column A and B. Put your dates in column C (the X axis of your chart), then in column D you can write =COUNTIFS($A$1:$A$1000,"<="&C1,$A$1:$A$1000,">="&C1). The COUNTIFS function will consider that for each row of data, all conditions must be met to be added to the count (a little weird, but definitely useful). See screenshot.
Calculate average based on a value column (count) in a pivot table
I'm looking a way to add an extra column in a pivot table that that averages the sum of the count for the months ("Count of records" column) within a time period that is selected (currently 2016 - one month, 2017 - full year, 2018 - 5 month). Every month would have the same number based on the year average, needs to be dynamically changing when selecting different period: full year or for example 4 months. I need the column within the pivot table, so it could be used for a future pivot chart. I can't simply use average as all my records appear only once and I use Count to aggregate those numbers ("Count of records" column). My current data looks like this: The final result should look like this: I assume that it somehow can be done with the help of "calculated filed" option but I couldn't make it work now. Greatly appreciate any help!
Using the DataModel (built in to Excel 2013 and later) you can write really cool formulas inside PivotTables called Measures that can do this kind of thing. Take the example below: As you can see, the Cust Count & Average field gives a count of transactions by month but also gives the average of those monthly readings for the subtotal lines (i.e. the 2017 Total and 2018 Total lines) using the below DAX formula: =AVERAGEX(SUMMARIZE(Table1,[Customer (Month)],"x",COUNTA(Table1[Customer])),[x]) That just says "Summarize this table by count of the customer field by month, call the resulting summarization field 'x', and then give me the average of that field x". Because DAX measures are executed within the context of the PivotTable, you get the count that you want for months, and you get the average that you want for the yearly subtotals. Hard to explain, but demonstrates that DAX can certainly do this for you. See my answer at the following link for an example of how to add data to the DataModel and how to subsequently write measures: Using the Excel SMALL function with filtering criteria AND ignoring zeros I also recommend grabbing yourself a book called Supercharge Excel when you learn to write DAX by Matt Allington, and perhaps even taking his awesome online course, because it covers this kind of thing very well, and will save you significant head-scratching compared to going it alone.
Index Match Match across multiple columns
I have an Index Match Match question that I have not been able to find the answer for in researching. Although the solution may actually might be different than an Index Match Match formula - I'm open to try something more efficient than my current workaround. I have one worksheet with data from my company on it. We sell a Product (let's call it Coke Zero) and we track the weeks that we put a promotion on and how much profit we make by selling it to the retailer. For example a promotion for Coke Zero starts the first week of Jan and ends 3 weeks later and we make a gross profit of $100 each week the promotion runs. I then have an external database with sales data formatted on a weekly basis to tell me how many units of Coke Zero I sold in each week. My internal data has thousands of lines like this with dozens of products, however the promotions are consolidated on one single row regardless of if it runs for more than one week, making matching up to the external database difficult. I need to create a lookup for what our Gross Profit was for each week of the promotion. I have attached an example image of the workbook + two data sheets of what I've tried to do, summarised below. On the Internal Data Sheet I've created additional columns to the right with all of the weeks listed that the promotion is on for, and concatenated them with the Product Code to be able to match week by week to the data in the External data sheet. Then my lookup basically checks every column one after another until it finds one where the concatenate of Week_Product Code concatenate matches. My current solution technically works but my final formula is really slow and cumbersome given the data can be anywhere from 10K-200K lines when looking at multiple retailers. I was hoping to find a more efficient formula to complete the lookup. Current solution on the External Data Sheet Column E: =IF(ISNUMBER(MATCH(D2,'Internal Data'!$E:$E,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$E:$E,0)), IF(ISNUMBER(MATCH(D2,'Internal Data'!$F:$F,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$F:$F,0)), IF(ISNUMBER(MATCH(D2,'Internal Data'!$G:$G,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$G:$G,0)), "0")))
I got SUMPRODUCT to work using this formula in J2: =SUMPRODUCT(--($B$2:$D$3=H2)*--($E$2:$E$3=I2)*$F$2:$F$3) And, you don't need those concatenated lookup columns: Well, that was fun.