countifs and remove data completed

Bazabelle

New Member
Joined
Oct 6, 2022
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am struggling to have a formulas that would count the planning for future months but if it actually occurred, I need to remove them from the future month, if I just use the minus option of the previous month, I may get an error or inaccurate information.

I do not have the option to use XL2BB, hope the tables are pasting well.

Thanks in advance.

TABLE WITH FORMULAS:

Column AColumn BColumn CColumn DColumn EColumn FColumn GColumn HColumn I
UIDPerson NameAssignedCountriesNb Initial PlanNb Current Work01-Jan-2401-Feb-2401-Mar-24
IF(COUNTIFS(RAWDATA!$A:$A,$A3,RAWDATA!$AP:$AP,"<=01/31/2024",RAWDATA!$AP:$AP,">=01/01/2024")=0,"",COUNTIFS(RAWDATA!$A:$A,$A3,RAWDATA!$AP:$AP,"<=01/31/2024",RAWDATA!$AP:$AP,">=01/01/2024"))IF(COUNTIFS(RAWDATA!$A:$A,$A3,RAWDATA!$AO:$AO,"<=02/29/2024",RAWDATA!$AO:$AO,">=02/01/2024")=0,"",COUNTIFS(RAWDATA!$A:$A,$A3,RAWDATA!$AO:$AO,"<=02/29/2024",RAWDATA!$AO:$AO,">=02/01/2024"))IF(COUNTIFS(RAWDATA!$A:$A,$A3,RAWDATA!$AO:$AO,"<=03/31/2024",RAWDATA!$AO:$AO,">=03/01/2024")=0,"",COUNTIFS(RAWDATA!$A:$A,$A3,RAWDATA!$AO:$AO,"<=03/31/2024",RAWDATA!$AO:$AO,">=03/01/2024"))
Canada1234/56781234/5678Canada111<- This needs to be 1
IF(COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AP:$AP,"<=01/31/2024",RAWDATA!$AP:$AP,">=01/01/2024")=0,"",COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AP:$AP,"<=01/31/2024",RAWDATA!$AP:$AP,">=01/01/2024"))IF(COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AO:$AO,"<=02/29/2024",RAWDATA!$AO:$AO,">=02/01/2024")=0,"",COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AO:$AO,"<=02/29/2024",RAWDATA!$AO:$AO,">=02/01/2024"))IF(COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AO:$AO,"<=03/31/2024",RAWDATA!$AO:$AO,">=03/01/2024")=0,"",COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AO:$AO,"<=03/31/2024",RAWDATA!$AO:$AO,">=03/01/2024"))
Colombia1234/56781234/5678Colombia1421214<- This should return 2

TABLE WITH DATA (called RAWDATA):

Column AColumn BColumn CColumn DColumn APColumn AO
UIDDate PlanDate Actual
Colombia1234/5678Colombia1234/567819-Mar-2024
Colombia1234/5678Colombia1234/567820-Mar-2024
Colombia1234/5678Colombia1234/567805-Mar-202430-Jan-2024
Colombia1234/5678Colombia1234/567808-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567808-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567811-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567811-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567812-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567812-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567813-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567813-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567814-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567814-Mar-202431-Jan-2024
Colombia1234/5678Colombia1234/567815-Mar-202431-Jan-2024
Canada1234/5678Canada1234/567813-Mar-2024
Canada1234/5678Canada1234/567821-Mar-202221-Mar-2022
Canada1234/5678Canada1234/567823-Jan-202320-Jan-2023
Canada1234/5678Canada1234/567802-Sep-202201-Sep-2022
Canada1234/5678Canada1234/567807-Sep-202205-Sep-2022
Canada1234/5678Canada1234/567817-Feb-202309-Jan-2023
Canada1234/5678Canada1234/567812-Sep-202212-Sep-2022
Canada1234/5678Canada1234/567816-Sep-202215-Sep-2022
Canada1234/5678Canada1234/567820-Sep-202220-Sep-2022
Canada1234/5678Canada1234/567822-May-202319-May-2023
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I think I might have work out why the formula you provided did not work as expected. When you put 03/31/2024 and 03/01/2024 for comparison inside COUNTIFS function, those value does not translate to equivalent the Excel sequence representing those dates but performed the calculation 3 divided by 31 divided by 2024. Instead, if you want to hardcode those dates, try <=DATEVALUE ("03/31/2024") and >=DATEVALUE ("03/01/2024") for the comparison.
 
Upvote 0
Was not able to add some expended answer after the 10-minutes limitation for editing answer.

It's also possible to refer the date in another cell. Based on the sample formulas you provided, assuming cell $I$1 contains the date 03/01/2024, so <=EOMONTH ($I$1,0) and >=$I$1 for those comparison might be more appropriate. Then again, you might have good reason to hardcode those dates inside your COUNTIFS functions.
 
Upvote 0
😳Sorry the solution I give was not correct. the correct way should be: "<="&"03/31/2024" and ">="&"03/01/2024", tricky part is the need to concatenate (using &) the comparison operators and dates as string/text type. Use of DATEVALUE is redundant then.
For using cell as reference also need to use the & like: "<="&EOMONTH ($I$1,0) and ">="&$I$1
 
Upvote 0
😳Sorry the solution I give was not correct. the correct way should be: "<="&"03/31/2024" and ">="&"03/01/2024", tricky part is the need to concatenate (using &) the comparison operators and dates as string/text type. Use of DATEVALUE is redundant then.
For using cell as reference also need to use the & like: "<="&EOMONTH ($I$1,0) and ">="&$I$1
So even if I would try this (I did not yet), my columns would still have the data reporting "14" for Colombia because there are those dates, what mostly I need is how to combine a search from one column, if the data is already there, then not to count those cells in the other columns.
 
Upvote 0
Sorry for rushing in to answer this question without fully understand it. I had my own question, searching for possible solutions when I saw this question under the Unanswered Section and thought it’s simpler. Should have spent more time to understand the question correctly. Since I already moved this question out of Unanswered Section. I’ll spend more time trying to figure out.

I don’t fully understand what you mean by ‘actually occurred’. Is this reflected some way in the data? It looks like from your sample data, it’s where Date Actual have a date (not empty) in Column AO?

Also, what exactly do you mean by ‘minus option of the previous month’? Like subtracting Column H from Column I?

In the Formula Sheet, Column G, you check Jan 2024 against RAWDATA!$AP:$AP, but for Column H & Column I, check Feb 2024 & Mar 2024 against RAWDATA!$AO:$AO instead, why?

The placing of Column AO and Column AP in the sample out of normal order, also add the confusion.
 
Upvote 0
Hope I finally understood what you trying to do
So even if I would try this (I did not yet), my columns would still have the data reporting "14" for Colombia because there are those dates, what mostly I need is how to combine a search from one column, if the data is already there, then not to count those cells in the other columns.
I don’t fully understand what you mean by ‘actually occurred’. Is this reflected some way in the data? It looks like from your sample data, it’s where Date Actual have a date (not empty) in Column AO?
Assuming 'actually occurred’ is reflected by where the Date Actual have a date (not empty) in Column AO

You were very close with your original formula just add another condition: RAWDATA!$AO:$AO,"" within all the COUNTIFS, use RAWDATA!$AP:$AP for criteria_range comparing the date (you used RAWDATA!$AO:$AO under Column I Mar 2024 for some reason), so
Excel Formula:
=IF(COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AP:$AP,"<=03/31/2024",RAWDATA!$AP:$AP,">=03/01/2024",RAWDATA!$AO:$AO,"")=0,"",COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AP:$AP,"<=03/31/2024",RAWDATA!$AP:$AP,">=03/01/2024",RAWDATA!$AO:$AO,""))
got me 2 when copied your sample and actually test it this time. (Note: I used the dd/mm/yyyy format 31/03/2024, 01/03/2024 when tested it, but the quoted formula above follows date convention in your formula sample)

Also, I noticed you're using version 365, so I think it's better to construct the Formula using LET, making it easier to modify and fix any issue. I don't have the access to the 365 version right now, so can't test that approach.
 
Last edited:
Upvote 0
In the Formula Sheet, Column G, you check Jan 2024 against RAWDATA!$AP:$AP, but for Column H & Column I, check Feb 2024 & Mar 2024 against RAWDATA!$AO:$AO instead, why?
So January (Summary - column G) I count only the actuals which are in RAWDATA-Column AP, the other months are planned numbers I need to see for projections, but I do not want to count the ones done in RAWDATA-Column AP that are also planned in RAWDATA-Column AO
Excel Formula:
=IF(COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AP:$AP,"<=03/31/2024",RAWDATA!$AP:$AP,">=03/01/2024",RAWDATA!$AO:$AO,"")=0,"",COUNTIFS(RAWDATA!$A:$A,$A5,RAWDATA!$AP:$AP,"<=03/31/2024",RAWDATA!$AP:$AP,">=03/01/2024",RAWDATA!$AO:$AO,""))
I added it on my side but it is not showing me anything, it returns empty. I also tried changing the format date in case but same situation it remains empty.

I am not that of an expert to convert with the LET formula :(
 
Upvote 0
The Excel workbook you have built is probably more complex than what I can infer from the sample you provided. Without knowing the exact way you set up your data, I assumed the column RAWDATA!AO the one use to determine if the data already there or not. To be more specific I thought cell RAWDATA!$AO$2, RAWDATA!$AO$3, RAWDATA!$AO$16 in your sample are blanks without data. That was the additional criteria_range my formula was based on. Correct me if I am wrong in this part of assumption.
My understanding for the indented result based on your formula logics is count the ones matching particular value of UID AND matching the Month in Date Plan AND where Date Actual do not have any value (like dates in your sample) entered.
So January (Summary - column G) I count only the actuals which are in RAWDATA-Column AP, the other months are planned numbers I need to see for projections, but I do not want to count the ones done in RAWDATA-Column AP that are also planned in RAWDATA-Column AO
In your sample data, the column RAWDATA!AP you had the heading: Date Plan, but it’s for the ones done; RAWDATA!AO you had the heading: Date Actual, but actually for planned in? Note also you ordered column RAWDATA!AO on the RHS of column RAWDATA!AP in your sample.
I added it on my side but it is not showing me anything, it returns empty. I also tried changing the format date in case but same situation it remains empty.
It would return empty if the COUNIF function returns 0, that was the logic you have built into your sample formula. You can easily verify by running the COUNIF function by itself independently. On your side maybe you have something in cell RAWDATA!$AO$2, RAWDATA!$AO$3, RAWDATA!$AO16? Since your original formula returned 14, I think the other criteria_ranges and criterias in your formula are working as intended.

Unsure if I can spend more time until the weekend, hope others could provide some help. Is there anyone that can help you in person? Since they're able to have closer look at how the actually Excel workbook is set up.
 
Upvote 0
The Excel workbook you have built is probably more complex than what I can infer from the sample you provided. Without knowing the exact way you set up your data, I assumed the column RAWDATA!AO the one use to determine if the data already there or not. To be more specific I thought cell RAWDATA!$AO$2, RAWDATA!$AO$3, RAWDATA!$AO$16 in your sample are blanks without data. That was the additional criteria_range my formula was based on. Correct me if I am wrong in this part of assumption.
My understanding for the indented result based on your formula logics is count the ones matching particular value of UID AND matching the Month in Date Plan AND where Date Actual do not have any value (like dates in your sample) entered.

In your sample data, the column RAWDATA!AP you had the heading: Date Plan, but it’s for the ones done; RAWDATA!AO you had the heading: Date Actual, but actually for planned in? Note also you ordered column RAWDATA!AO on the RHS of column RAWDATA!AP in your sample.

It would return empty if the COUNIF function returns 0, that was the logic you have built into your sample formula. You can easily verify by running the COUNIF function by itself independently. On your side maybe you have something in cell RAWDATA!$AO$2, RAWDATA!$AO$3, RAWDATA!$AO16? Since your original formula returned 14, I think the other criteria_ranges and criterias in your formula are working as intended.

Unsure if I can spend more time until the weekend, hope others could provide some help. Is there anyone that can help you in person? Since they're able to have closer look at how the actually Excel workbook is set up.
Thanks, I mixed the 2 columns trying to copy/paste here. I will try later to convert this with the XL2BB. I do not have a in person that can walk me through, it is not urgent fix so I can still wait when you have more time and when I can add the file in the format that will make it easier for you to understand. I truly appreciate all the time you have currently gone for this.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top