Hi Everyone
First of all, I'm come from Vietnam so I'm sorry for my bad English.
I dont know how to describe the question more clealy so please see the attached file for details.
Any help would be appreciated.
Hi Everyone
First of all, I'm come from Vietnam so I'm sorry for my bad English.
I dont know how to describe the question more clealy so please see the attached file for details.
Any help would be appreciated.
Last edited by congnt92; 08-25-2018 at 12:38 PM. Reason: Re-upload
Welcome to the forum!
Your two arrays look identical to me, so I have no idea what you are trying to do.
Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.
1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.
2. Make sure that your desired results are also shown (mock up the results manually).
3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).
4. Try to avoid using merged cells as they cause lots of problems.
Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
Ali
Enthusiastic self-taught user of MS Excel who's always learning!
Don't forget to say "thank you" in your thread to anyone who has offered you help.
You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.
Forum Rules (updated August 2023): please read them here.
My mind reading device is saying
=INDEX($1:$1,ROW(A1)) to convert a row to a column or
=INDEX($A:$A,COLUMN(A1)) to covert a column to a row.
Mind reading device does need new batteries though not quite sure how you intend to get a matrix from a single row or column
Hi AliGW,
Thank for your quick reply.
Please see the attached document
Many tks.
So this is homework?
Nothing is more frustrating than to be working on homework and to get stuck. Without guidance, you might have no hope of finishing the assignment before the deadline. The Internet can be a big help in that respect, but without learning how to get the right answer, asking others to solve your homework questions for you simply becomes a downward spiral (and it's cheating).
We do not want to contribute to you cheating yourself out of your education, but we also acknowledge that seeking assistance to learn a concept is a legitimate request.
If you are genuinely interested in receiving help in the form of tutoring or coaching, then please rephrase the title of your original post to clearly indicate you are seeking coaching or tutoring help. Any forum members (who are willing to assist as a tutor) will modify their responses accordingly to facilitate your learning. Tutors don't tell you the answers, they help you figure it out for yourself; so don't expect answers, expect suggestions, or just plain hints. Also, be specific in describing the function/formula or technique you trying to learn, and tell us what you have attempted so far. Otherwise, expect your plea for homework answers to be ignored.
See post #5.
Hi AliGW
Because of it is homework then I tried my best to get the answer by myself.
The original question is get the smallest value of sum start-end point of each code.
I have idea fr it but I just cannot find the solution how can I convert an array such as
{-2.8;0;0;0;-17.8;-2.5;0;0;0;0;-15.9;0} (1 row)
to {-2.8,-17.8;-2.5,-15.9} (2R x 2C)
Since I'm new with array formula then I start from here.
Hope you can give me some hints.
Tks.
Last edited by AliGW; 08-25-2018 at 12:36 PM.
If you're trying to transpose the data so that, for example, all B210 values are in the first row of the array, all B211 values in the second row, etc. Then you need to step back and look at it differently.
That would only work if the result would be an eqaul number of columns for every row, meaning that you would need to have the same number of every code in your data source. In your sample, you have 5 of the first code and 6 of the second, so the theory fails before you begin.
Is the data sorted by code, or is it permissable to do so? Match functions love sorted data
@Ali. I just solved it using the {1} method that we were discussing last week. Do you have any alternative thoughts?
Last edited by jason.b75; 08-25-2018 at 12:38 PM.
I'm afraid not at the moment. I'm not really quite getting what the OP is after. And I'm just about to go offline for the evening.
I'll be interested to see how this has developed when I look in again in the morning.
For what it's worth, the 'solution' could be very much excel version related. I'm thinking of one thing that should work, but I don't have the correct version of excel to test it.
Post deleted
Last edited by Bosco; 08-25-2018 at 02:07 PM. Reason: Homework as per notice
Bosco, please delete your reply, then read post #5.
For the benefit of others:
Excel 2016 (Windows) 32 bit
A B C D E F 1Code Value Hi everyone. I'm so sorry for my bad English. 2 B210 -2.8 0I have a homework about using just 1 array formula sum 2 values of start and end-point then compare them to get smallest value 3 B210 9.9B210 starts at row 2, ends at row 6. 4 B210 -5.7B210 starts at row 7, ends at row 12. 5 B210 -13.6I have to sum value at B2 with B6, sum value at B7 with B12 and then compare them to get smaller value 6 B210 -17.8I mean 7 B211 -2.5(-2.8) + (-17.8) = (-20.6) 8 B211 7.9compare with 9 B211 7.9(-2.5) + (-15.9) = (-18.4) 10 B211 -4.7So min(-20.6,-18.4) is -20.6 11 B211 -12.3The real data is very large, not just B210 and B211. Maybe B212, B213 … and so on. So I need a generic formula for it. 12 B211 -15.9 13My idea is get values like this (array formula in C2) 14{-2.8;0;0;0;-17.8;-2.5;0;0;0;0;-15.9;0} 15Then by some how we have 16{-2.8,-17.8;-2.5,-15.9} 17Finally we using mmult and min like this 18MIN(MMULT({-2.8,-17.8;-2.5,-15.9},{1;1})) 19result is -20.6
Sheet: Sheet1
So, to summarise:
1. You want to take the first and last entries for each code number and add them together.
2. Then you want to find the minimum of all these numbers.
You are correct that your final MMULT formula gives the correct answer.
Hi Jason,
About match formula I tried
MATCH(value,range,{1,2})
but no luck.
Hi AliGW
Yes you're right.
My idea is some how I can convert a vector with 1 row to 2R x 2C and then I can using MIN + MMULT to do the rest.
I'm getting stuck at find a technique to do that.
Yes - I understand. Thanks for clarifying.
When you say this is homework, what is the level of the course you are undertaking?
What did you use to get the array that you show in F14 of your sample file?
I see evidence of the use of FREQUENCY, but would like to see your actual method.
Jason - I think it's this one in C2 (array entered):
=IFERROR(($B$2:$B$12)/(($A$2:$A$12<>$A$3:$A$13)<>($A$2:$A$12<>$A$1:$A$12)),0)
If you evaluate, you should see the array generated.
Hi AliGW
Actually, my teacher is retired Office informatics teacher in an university. He open a "mini course" (at his home) for someone that want to study Excel array formula.
In class, we will tell the ideas to solve an exercise and then discuss which idea is the best and how to do it with array formula.
This homework is one of them. So it's difficult to tell the level of this course.
This is your actual data. As per your file you only add code / value only.
Actually if your data with some logical, its make the difference. i.e. Invoice-Number, Invoice-Date, Code, Nam, Value. or some more.
atul
If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.
Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".
Ah! So your teacher doesn't know how to do it yet, either? Well, that makes sense.In class, we will tell the ideas to solve an exercise and then discuss which idea is the best and how to do it with array formula.
I think the way forward is to discuss it here, too.
Given what the OP has just told us, i.e. this is all theoretical/exploratory, I think we have to assume that he has given us enough relevant information.This is your actual data. As per your file you only add code / value only.
For Post #20 "Congnt92.
As my thinking, you want sum first & last value of particular code.
In this case you create add one more column for example "Date".
Secondly, you pull of unique code in another column. Then start & end date & applying sum formula with criteria.
Between sum range you can pull out Min.
For more clarity refer attach file.
Hi AliGW
My teacher will give us the answer in the next week.
In the next week, I and other student will describe our methods and how to do it with formula.
I have an idea as in the attached file but getting stuck before end it with MMULT :D
Hi avk,
This is my actual data. It is just an exercise, nothing more.
To be more clearly what this course does, I attach another exercise that we solved in last week.
Tks.
AVK - that makes the problem very easy to solve, however I really believe the challenge is to do it without helper columns. The OP has specifically stated this in post #20:
I think we need to stick to that brief.... how to do it with array formula.
Thanks, Ali! I missed that formula! Too busy looking at ways to make it more complicated than I needed too
There was a mistake in your formula which was not helping your progress, this was producing the final 0 at the end of the array which should not have been there.
=IFERROR(($B$2:$B$12)/(($A$2:$A$12<>$A$3:$A$13)<>($A$2:$A$12<>$A$1:$A$12)),0)
The final array is one row more than the others, what you should have done is adjusted both the first and last row in the range to keep the cell count equal to the rest, the same as you did with $A$3:$A$13
Then if you enclose the whole formula in MIN() I think it should be as simple as adjusting the mathematical operations to get the desired result.
Thanks.
Hi Jason.
It is my mistake.
The formula must be
IFERROR(($B$2:$B$12)/(($A$2:$A$12<>$A$3:$A$13)<>($A$2:$A$12<>$A$1:$A$11)),0)
Tks.
Last edited by AliGW; 08-26-2018 at 08:34 AM.
Or...................
Try this single formula without helper
In C2, enter :
=MIN(SUM(INDEX(B2:B12,N(IF(1,AGGREGATE({15,14},6,ROW(A2:A12)-ROW(A1)/(A2:A12="B210"),1))))),SUM(INDEX(B2:B12,N(IF(1,AGGREGATE({15,14},6,ROW(A2:A12)-ROW(A1)/(A2:A12="B211"),1))))))
The result is -20.6
Regards
Bosco
Bosco - this requires each of the code sections to be defined. The idea is not to have to do this. The OP wants a formula that will work with any size of dataset with any number of code sections.
Please read through post #14 to understand what is required.
Last edited by AliGW; 08-26-2018 at 10:11 AM.
Found a way to get your 2 column array, but there is still work to do.
First you need to split your existing formula into 2 parts. 1 that returns the first value for each code, another that returns the last.
Nest each or those arrays into CHOOSE with a {1,2} index number.
The downside is that the zero's returned by IFERROR are still populated in the array, if you can find a way to omit them then you should be able to do what you want, although I think it will result in a very long and complex formula.
I've done it using a different approach, with 5 functions nested inside the first array of MMULT without transposing.
I generated the array, 2 columns, 1 row, with unconventional use of VLOOKUP. There is a thread started by Ali, about a week ago, where this unconventional method was suggested and discussed. If you can find it then it might give you some ideas.
The thread to which Jason refers is here: https://www.excelforum.com/excel-for...n-the-fly.html
Thanks, Ali! I had a look at my post history but couldn't see it, think I unsubscribed in error.
Hi Bosco,
Thank for your help but I need for a generic formula. With it we can solved not for only 2 codes.
I was think about it too. But I still not get it to work.
Thank, Ali. Very useful link. Although it seems not related with this topic but i've learn about using array value for vlookup with {1} technique.
Last edited by AliGW; 08-26-2018 at 11:24 AM.
It is related to this topic, I can assure you, because Jason has solved your problem using the techniques discussed there and shared that solution with me.
As this is homework, he won't share his solution with you here until after you have posted the solution given by your teacher. However, if you post ideas that you might have regarding the VLOOKUP trick, I am sure he will let you know if you are on the right track or not.
Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!
For normal conversational replies, try using the QUICK REPLY box below.
You say that the link is not related, but the method using {1} is the one that I have used to get the correct answer to your question
Try rethinking your arrays
MMULT({-2.8;-2.8;-2.8;-2.8;-2.8;-2.5;-2.5;-2.5;-2.5;-2.5;-2.5,-17.8;-17.8;-17.8;-17.8;-17.8;-15.9;-15.9;-15.9;-15.9;-15.9;-15.9},{1;1})
Hi Jason, Ali
Thank for the hint.
I tried
=VLOOKUP(T(IF({1},$B$3:$B$13,)),$B$3:$D$13,3,0) and get {-2.8;-2.8;-2.8;-2.8;-2.8;-2.5;-2.5;-2.5;-2.5;-2.5;-2.5}
Since vlookup will return the first result so I do not know how to get -17.8 and -15.9
May I must combine vlookup and lookup ??
Think about the role of the four different arguments in the VLOOKUP function. One of them is the key to being able to generate an array with all of the numbers you need. Also, remember that Jason said this:
I've done it using a different approach, with 5 functions nested inside the first array of MMULT without transposing.
Last edited by jason.b75; 08-27-2018 at 03:42 AM.
Hi Ali, Jason
This formula work for me.
=MIN((VLOOKUP(T(IF({1},$A$2:$A$12,)),$A$2:$B$12,2,0)+VLOOKUP(T(IF({1},$A$2:$A$12,)),$A$2:$B$12,2,1))/2)
Data must be sorted by code A to Z.
But i have 2 questions about this technique
- Why we must use T formula. The code already is text by itself. I think no need to use T but the formula will not work if remove T
- How can I use something like this
vlookup(value, range, column, {0,1})
so we can have a shorter formula.
Tks.
Well done! It's different from Jason's solution but uses the same techniques.
Hi Ali, Jason
This formula works, too.
=MIN(MMULT(N(OFFSET($B$1,MATCH($A$2:$A$12,$A$2:$A$12,{0,1}),)),{1;1}))
Still do not know why we need T for vlookup and how we can using {0,1} in vlookup like match.
Have a look at Ali's thread, the logic was discussed there.
An array alone is of no use. {=IF(A2:A12="B211",B2:B12)} will return FALSE because there is nothing to use the array, the result will only ever be the first value in the array, however {=SUM(IF(A2:A12="B211",B2:B12))} will return -19.6 because you now have the SUM function to do something useful with the array.
Think outside the box, T() is for text...
Your formula in post #44 is impressive.
I'm trying to break it down a bit and see if it can be used with unsorted codes.
Hi Jason
+) I know T() is for text but $A$2:$A$12 already is text so why we must use T()
We just need IF({1},$A$2:$A$12,)
(But formula will not works. I don't know why.)
+) We can use {0,1} for match_type in match formula. What about vlookup. I tried the same with vlookup but it just return match_type 0.
Tks.
Try reading my post again, I quoted to lines from your post with a response to each of those. It looks like you might be mixing them up.
{0,1} is only woking in your formula with MATCH because of something else you have done, you just might not have realised it.
Hi Jason
From the given link, I understand that T() will convert a range to "array reference", right?
Also, my teacher show us the solution for this excercise.
- Create a vector of start and end point of each code: {1;5;6;11} (note: area is A2:A12)
- Convert a vector to {1,5;6,11} using AGGREGATE(15,6,vector,k) with k is a matrix like this {1,2;3,4}
The technique is:
(ROW(1:2)-1)*2+{1,2}
In my example, we have 2 codes so the generic formula is (ROW(1:n)-1)*2+{1,2}
- Using offset() to get {-2.8,-17.8;-2.5,-15.9}
Min and MMULT will do the rest job.
Full formula is:
MIN(MMULT(N(OFFSET($B$1,AGGREGATE(15,6,MATCH($A$2:$A$12,$A$2:$A$12,{0,1})/($A$2:$A$12<>$A$3:$A$13),(ROW(INDIRECT("1:"&SUMPRODUCT(1/COUNTIF($A$2:$A$12,$A$2:$A$12))))-1)*2+{1,2}),)),{1;1}))
So the thing we learn from this example just simple is technique to convert an 1 R/C array to matrix.
Thanks Ali, Jason, Bosco, avk for your help.
P/S: I still follow this topic to get more great methods from you.
Tks.
Last edited by congnt92; 08-27-2018 at 06:05 AM.
IF({1},range) creates the array, but as I stated earlier, the array alone is useless. I think to say that T() then manipulates that into something useful would be a more accurate analysis.
Personal opinion, your formula is significantly better than your teacher's!
Your teacher would have beaten us if the formula produced the correct result with the codes not sorted in ascending order, but given that they all fail in that respect, we get a tie.
Your method,
=MIN(MMULT(N(OFFSET($B$1,MATCH($A$2:$A$12,$A$2:$A$12,{0,1}),)),{1;1}))
uses less functions and arrays, so might be slighlty more efficient in terms of processing, but I'm docking points for the use of a volatile function (something to ask your teacher about if you haven't heard that before).
The most concise formula that I could think of was
=MIN(MMULT(VLOOKUP(T(IF({1},$A$2:$A$12)),$A$2:$B$12,2,N(IF({1},{0,1}))),{1;1}))
Which was the one we were hinting towards.
Think we might need to disect your teacher's formula as well, see if we can improve it
As it is based on AGGREGATE, I think that is your area of expertise, Bosco!
I think the challenge is still on: can anyone crack this to work with the codes in any order?
This has been a particularly enjoyable thread because of the working out we have seen along the way.
This behemoth variation of the 'solution' works with ascending, or descending, but not random order. Still giving that some thought.
=MIN(MMULT(N(OFFSET($B$1,AGGREGATE(15,6,CHOOSE({1,2},MATCH($A$2:$A$12,$A$2:$A$12,0)/($A$2:$A$12<>$A$3:$A$13),(MATCH($A$2:$A$12,$A$2:$A$12,0)+COUNTIF($A$2:$A$12,$A$2:$A$12)-1)/($A$2:$A$12<>$A$3:$A$13)),(ROW(INDIRECT("1:"&SUMPRODUCT(1/COUNTIF($A$2:$A$12,$A$2:$A$12))))-1)*2+{1,2}),)),{1;1}))
Hi Jason
Your vlookup with {0,1} for match_type works fine.
My teacher does not have any idea about random order because he build his own data in order to show us how to convert an 1R/C array to matrix.
From the start, our data was sort A-Z or Z-A.
If data was sort from Z-A then just change match_type to {0,-1}.
So can it be done with a random order in the values column?
It should be possible with max(row(if, but I'm having brainfreeze on simple stuff today
Match() requires data must be sort with a specific order for match_type 1/-1. AGGREGATE helps us avoid it.
But at least if we are using AGGREGATE then the data must be contiguous (no need to A-Z or Z-A).
Because AGGREGATE(15,...) sort position of start and end point of each code from smallest to largest.
If B210 start 1, end 5, B211 start 2 end 7 then AGGREGATE will return {1,2;5,7} and then the result will not true. (it must be: {1,5;2,7})
If the data is contiguous then this will work
=MIN(MMULT(N(OFFSET($B$1,AGGREGATE(15,6,ROW(1:11)/((COUNTIF(OFFSET($A$2,,,ROW(1:11),),$A$2:$A$12)=1)+(COUNTIF(OFFSET($A$2,,,ROW(1:11),),$A$2:$A$12)=COUNTIF($A$2:$A$12,$A$2:$A$12))),{1,2;3,4;5,6}),)),{1;1}))
The technique to create {1,2;3,4;5,6} we already know.
Capture1.PNG
Last edited by congnt92; 08-27-2018 at 10:40 PM. Reason: upload IMG
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks