Calculate unique dates from multiple columns - excel

I have three ranges of dates in Columns B7:B38, F7:F38 and K7:K38. Some dates are duplicates and some dates are unique. Some columns contains few values, and some columns are full. Which formula I can use to calculate unique dates value?
I find formula that work fine for one range, but can't figure out how to compare multiple ranges
=SUMPRODUCT(1/COUNTIF(B7:B38;B7:B38))
If I use COUNTIFS for multiple ranges
=SUMPRODUCT(1/COUNTIFS(B7:B38;B7:B38;F7:F38;F7:F38;K7:K38;K7:K38))
it calculate only one longest range of values.
Any advices? Thank you!

Hello Igor Oleksandrov,
I could not manage to do it in one formula but I think I have a solution for you: List the contents of your ranges with two passes of the small function. The Duplicates can be removed with some comparing in the middle.
In the first version of my answer I put the ranges in a name. That might be handy and nice, but luckily the small function can handle multiple ranges when in ().

Related

Finding the sum of dates using first column value

So I am working in excel and have two columns, as shown below.
What I wish to do is to able to get the sum of yearly deadlines for A, B and C.
So that:
Get a sum of dates within Year 2020 for each Variable
Get a sum of dates within Month/Year for each specific A,B and C.
Currently, I have been using a long approach. I use a Vlookup for each row getting a filtered table for each Variable. Then using that I filter out Dates using combination of Countif and Countifs. But the problem with that approach is that I end up getting huge rows and table of data in the end increasing the file size.
I have also tried to use sumproduct() but I do not have numbers so I can not find a sum.
Is there a smart way of doing it using one formula?
Thank you.
Use SUMPRODUCT. For year/variable:
=SUMPRODUCT(($A$2:$A$13=E2)*(YEAR($B$2:$B$13)=$F$1))
for month/year/variable:
=SUMPRODUCT(($A$2:$A$13=$E2)*(YEAR($B$2:$B$13)=$F$1)*(MONTH($B$2:$B$13)=G$1))

How to reproduce cells that are in the same row a certain time?

How to reproduce cells that are in the same row a certain time? Please see the screenshot.
Use INDEX function to reference each of your text ranges as a 1D range.
Then you just need to develop two counters. The first counter will increase by 1 every 4 columns, the other will reset/loop every 4 columns. Use these counter to pull the appropriate cell address from the INDEX Function.
The following formula increases by 1 every 4 columns:
=INT((COLUMN(A:A)-1)/4)+1
The following formula loops a count of 1 to 4 as its copied to the right:
=MOD(COLUMN(A:A)-1,4)+1
Combined with with an index you can use the following formulas:
Names
=INDEX($A$1:$G$1,INT((COLUMN(A:A)-1)/4)+1)
Letters
=INDEX($A$3:$D$3,MOD(COLUMN(A:A)-1,4)+1)
Note the formula will produce an error if you pull it too far to the right as it will run out of names in the index to reference. It will work for a maximum columns Number of Names X Number of Letters, or the Maximum number of columns in your spreadsheet, which ever is smaller.
If you have Excel O365 with dynamic arrays and the SEQUENCE function, you can use these formulas in a single cell.
The results will SPILL over the requisite number of Cells, and adjust if you change the data ranges.
I used Dynamic named ranges for the two rows of information you have, but you could use Tables, or other methods:
A7: =INDEX(myMonths,1,INT(SEQUENCE(,COLUMNS(myData)*COLUMNS(myMonths),1,1/COLUMNS(myData))))
A8: =INDEX(myData,1,MOD(-1+SEQUENCE(,COLUMNS(myData)*COLUMNS(myMonths)),COLUMNS(myData))+1)
I thought a bit and figured out a simple solution as shown in the screenshot.please see the formula here

How to qualify cells to include in addition (Excel)

I have a column of data that ranges from about 0-1500.
What I've been able to do so far is use the count function to create a table of how many of the data lie in certain ranges (0-50, 51-100, 101-500, etc)
How could I instead sum up the numbers in each column which are part of the above subgroups? Such as, the sum of all values between 0-50, the sum of all values between 51-100, etc.
I know some java, in which I would run a for loop with an if statement, but in excel I'm not sure how to use the if statement and apply it to a whole column.
Appreciate any advice.

Excel formula to say if a date range is available/unavailable from a list of date ranges?

I'm creating a booking system in Excel and need a formula to tell me if a given date range is available/unavailable from a list of date ranges (bookings).
There's an excellent article on Chandoo.org here about testing to see if two ranges of dates overlap. However the formula provided only works when comparing one set of date ranges to another single set of date ranges. Whereas I require this to work/search through a multitude of date ranges.
=IF(OR(y<a,b<x),"Do not overlap","Overlap")
Take the bookings below for example:
*Bookings*
Start Date End Date
25/01/2019 26/01/2019
29/01/2019 31/01/2019
01/02/2019 03/02/2019
Based on the above, the following dates are available:
21/01/2019 24/01/2019
27/01/2019 28/01/2019
If I fed the formula either of these two sets of dates, I would expect the outcome to read "Available".
Subsequently, the following dates are unavailable:
23/01/2019 26/01/2019
30/01/2019 02/02/2019
...and the formula should read "Unavailable".
As far as I'm aware, the logic around the formula from Chandoo.org does not work when converted to an array of search/compare criteria.
I thought I came close by using an array within two separate =COUNTIF() statements for each comparison y<a or b<x, however the outcomes weren't always correct.
The fact that a simple formula exists comparing two individual sets of date ranges makes me a believe a more complicated formula is derivable which compares a single date range to an array of date ranges.
Any help or guidance is much appreciated.
Thanks,
Mr J.
I hope this solution will help:
Assuming your actual Bookings are present in columns A&B (I copied your dates into cells A3:B5), and your four potential bookings are in columns D&E (cells D1:E4), you can paste the following formula for the first row:
=IF(COUNTIFS($A$3:$A$5,"<="&E1,$B$3:$B$5,">="&E1)+COUNTIFS($A$3:$A$5,"<="&D1,$B$3:$B$5,">="&D1),"Overlap","Do not overlap")
Drag & copy it to the remaining 3 rows. You should see "Do not overlap" for the first two dates and "Overlap" for the remaining two bookings. Let me know if this is what you were looking for.

Sorting formulas issue

I have a table which consists of names (1st column) avarageifs (2-6 columns) and average formulas (7 column).
Averageifs formula is taking the name to average values for each name:
=IFERROR(AVERAGEIFS(Grades!B:B,Grades!$A:$A,Rankings!$B14),"N/A")
"Total" average formula is:
=IFERROR(AVERAGE(C14:G14),0)
Then I am trying to sort it by "total" average, formulas are mixing up and referring to different rows.
But it should refer to the same row. What happens after sorting and how can I fix it?
Basically the references in the AVERAGEIFS formulae are getting swapped around and you don't want this to happen.
The easiest way round it would be to put the Totals column next to the Names column and just sort these two columns, leaving the other formulae in place.
If you don't want to do that, a fairly quick and dirty solution is to replace the AVERAGEIFS formulae with this so they always refer to the current row:-
=IFERROR(AVERAGEIFS(Grades!B:B,Grades!A:A,INDIRECT("Rankings!$B"&ROW())),"N/A")
See the discussion here

Resources