I'm having a formula in some cells which is based on values in other cells(say A1,B1) which in turn are getting populated from database.My formula is coming correct but it is always considering null value in A1,B1...ie,on opening my excel, the value in cells having formula is always zero..unless I change it in the generated excel.
I want it to consider cell values which are getting dynamically populated and then show the result.Please help!!!!!
In case your sheet has some formula for say A3=sum(A1:A2) is calculated and it is working fine with A1=5, A2 =4. Now if change the value of A2 with 2 like
sh.getRow(0).getCell(0).setCellValue(2); // set A1=2
and perform write operation, check the value of A3 it is still showing 9. It seems wrong but actully not. The point is that Excel caches previously calculated results and you need to trigger recalculation to updated them.
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
or with
wb.setForceFormulaRecalculation(true);
and then perform Write operation. This will give you the correct result. For Detail check here
Related
Im trying to count the duplicated values between the 2 row so im using the formula as you can see it in the image =SUM(COUNTIFS(E4:S4,{"1","2","3"}))
so I have to write the numbers so I dont want write the numbers I want select the cells instead, any formula would do that? I already searched and tried many things but nothing seem to work
Put those values in cells - and refer to those cells as condition.
Next level: insert those values in a table, that you eg. call FilterBy and the column values
Then you can us this formula:
=SUM(COUNTIFS(E4:S4,filterBy[Values]))
Hat I don't understand: why are you using SUM - like this, it doesn't make sense, as COUNTIFS returns one value.
If you want to some all filtered values then you need this formula:
=SUM(SUMIFS(E4:S4,E4:S4,filterBy[Values]))
I am trying to use the result of a TRANSFORM inside an IF statement where if the value returned in transform is blank, the value_if_true should look up the value of the previous cell, add one to it and show that, otherwise just show the result of the transform.
My issue is that the formula inside value_if_true, returns #VALUE even though on evaluation it is calculating the right value to return but if I replace it with a static text it works fine.
Below is what I'm trying to do:
{=IF(TRANSPOSE(Master!A7:A110)="",INDIRECT("RC[-1]",0)+1,TRANSPOSE(Master!A7:A110))}
This is what works:
{=IF(TRANSPOSE(Master!A7:A110)="","blah",TRANSPOSE(Master!A7:A110))}
Thank You!
Are you sure the value in RC[-1] is a number? If it is text and can't be converted to a number, then it will return #Value
Also, are you entering this array formula into a single cell and then filling it, or are you array-entering it into an entire range at once? If you're array-entering it into the entire range at once, then also be aware that RC[-1] will always refer to the cell that is to the left of the top-left cell of the output-array range.
Sorry for responding so late, surprisingly using named ranges instead of explicitly calling them out has solved the problem. To explain:
This is my data in the 'Reference' sheet. It is merely week numbers expressed in descending YYYYWW format:
201701
201702
201703
201704
201705
201706
201707
201708
The size of this list changes as data for more weeks flows in, the maximum items it can have is 104 weeks (two years rolling data). I've selected the entire 104 row range say $A$1:$A$104 that this list can expand to occupy and named it ListOfWeeks
On my display sheet I have selected the full 104 column range that these dates will be transposed into say $I$6:$DH$6 then entered the following formula into the formula bar:
=IF(TRANSPOSE(ListOfWeeks)=0,"",TRANSPOSE(ListOfWeeks))
followed by a Ctrl+Shift+Enter and it is working just fine.
I think I am seeing too many formulas now and have kind of hit a wall.
Basically I have a worksheet and it contains a value in cell A2. This is my current project phase
I then have a table, called 'Table1' and it has a column for 'Phase', which contains a range of unique values, one of which will match cell A2.
Also in Table1, I have another column called 'Overrun' which shows a Yes or No value to indicate that that phase has overrun (this is calculated by checking some dates).
So far so good.
I am now trying in a new cell (cell I2) to put a Yes or No if the CURRENT phase has the 'Overrun' value set to Yes. i.e. Where the Phase column matches cell A2, and the Overrun value for that phase is = Yes.
My query currently sits at this, but it is giving me a #VALUE result and I am not sure what I am missing:
=IF(AND(Table1[Phase]=A2,Table1[Overrun]="Yes"),"Yes","No").
My guess is that it is checking the full range of Overrun instead of the specific row for the current phase, but I am not sure how to check that with the AND.
Any help would be greatly appreciated.
Example of sheet - http://imgur.com/a/ETNrd
Chris
I suggest you look at the vlookup function, it should do what you want.
If the formula referencing the table is not in the same row as the table, then it shows #VALUE, like in the image. Note that I did add a $ to keep the A2 value constant across all of the rows.
Here is a resource about using structured references in excel tables.
I am using excel to create data sets that are used in a vba application later. I am using this formula:
=INDEX(BaseData!$L$2:$L$10000;MATCH(DataSet!D5&DataSet!E5&DataSet!K5;INDEX(BaseData!$B$2:$B$10000&BaseData!$C$2:$C$10000&BaseData!$D$2:$D$10000;0);0))
usually with a range from f.ex.: A2 - A10000, because my data can be differently long and often vary in data selection.
However, this slows my excel extremely down. I switched to manual calculations, but then, when activating automatic again, my excel instance takes extremely long and often crashes.
I also tried to past some data, but when creating a new dataset, I have to pull the formula down again and sometimes through this errors occur in my data set.
Any suggestions what I can do to make the INDEX-MATCH formulas more performant?
I appreciate your replies!
UPDATE
I guess a lot of performance goes away because index-match does not select the exact range, but also counts in blank rows. How to get the exactl range with index match automatically?
As I mention in my comment above, as long as this is a 'regular' formula and not an Array Formula, you may find success simply replacing "A1:A10000" with "A:A". However barring that, you can create a cell which will calculate reference the number of rows of data which you have, and then use that cell to indirectly reference the complete column with data in it.
CALCULATING YOUR DESIRED RANGE
For the following example to work, I assume that: Column A includes an index key in the form of numbers only; Column A includes no numbers in the header and above; and that the index rows are continuous, with no breaks. Start with the following formula:
=COUNT(A:A)
If my assumptions above hold, then this will return the number of data elements in your table. Once we know where this data starts, we can use this COUNT to determine where it ends. Assume your header is in row 2. (I like to include the header so that if you insert a row beneath the header, Excel picks up that you want to include the new row in your formulas).With that in mind, this formula will create the Excel-style reference which finds the last cell in column A which has data in it:
=ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1)
Assuming 50 rows of data [which start at row 3, below the header], and all other assumptions above, this formula will return the text result "$A$53".
If you wanted to do the same thing, but instead return the full range in Column A where data exists (from the header to row 53), you could do as follows:
=ADDRESS(ROW(A2),COLUMN(A2),1,1)&":"&ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1)
This returns the text string result "$A$2:$A$53", which is a reference to the full index of unique ID values. It will automatically move around as you would generally expect if you insert any rows or columns. Now assume for your INDEX that you want to pull the same data, but for column B, instead. The formula will be exactly the same, except that where I have "COLUMN(A2)" above, replace with "COLUMN(B2)".
REFERENCING YOUR CALCULATED RANGE
So now you have the address of your proper, limited columns - but how do you actually reference those areas in a formula? By using the INDIRECT function. INDIRECT says "Evaluate some specific criteria. It will create a cell reference. Now look at that cell reference." In its simplest form, this could look like this:
=INDIRECT(A1)
Assume that A1 holds the value "B5". Indirect will pick up the value "B5", and instead of displaying "B5", it will go to B5, and pick up the value there. So to use this with the above, wrap the whole thing in the INDIRECT function. Instead of picking up the text string "$A$1:$A$53", it will actually now reference that range properly. Like so:
=INDIRECT(ADDRESS(ROW(A2),COLUMN(A2),1,1)&":"&ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1))
USING A NAMED RANGE
But that is a very long formula to have, and you won't want to use it within a specific cell for a simple INDEX/MATCH. Instead of entering these formulas in cells (although you could), I recommend you go to the Formula Ribbon -> Name Manager -> New Name. Call the name for the index of A "ID_COLUMN". Call the name for the index of "B_COLUMN" (or something more specific).
FINAL FORMULA
Now, if you wanted to make an INDEX/MATCH of your table, which automatically grows/shrinks as you change the data, your formula would look like this [this would, for example, pick the row from column B where column A has the number 100]:
=INDEX(ID_COLUMN,MATCH(100, B_COLUMN, 0))
Reference Sheet:
https://docs.google.com/spreadsheets/d/1UQVeVLLuZbre_RL0H68K1yQ_3ybY3mRIBYPJUfmf1k0/edit?usp=sharing
In above reference sheet, under row, if I change the "alpha", into "beta" the corresponding value will return error #N/A since the formula is not able to find the name reference. But I am trying to keep the previous value, instead of showing #N/A.
Eg: currently formula looking for alpha and corresponding value is 10, so the VLOOKUP fill value field with 10. If I change alpha into beta in "Row", the previous populated value corresponding to alpha, ie 10, will change to #N/A since vlookup not able to find the name which is looking for. but I need to keep the previous value 10 there instead #N/A eventhough vlookup not able to find that.
A formula will always evaluate the current values of precedents and there is no way to conditionally revert to the previous values of these precedents.
What you describe can be achieved with macros, where the VBA can be used to store previous values in backup scenarios. Such a scenario might be doable for a few cells but is impractical for a large data set.
You may want to re-think your data architecture. There may be other approaches than the one you are asking for.
Actually, I was able to do this using a formula.
=IFNA(VLOOKUP(value, table, col_index, [range_lookup]),current_cell)
current_cell will be the cell you are placing your formula on.
The caveat in using this is that you will be creating a circular reference which might cause some of your calculations not work properly. But enabling iterations can be a work around for this.