How to evaluate a CSE formula using PhpSpreadsheet? - excel

I'm using PhpSpreadsheet (1.15.0) to generate a XLSX document with formulas.
One of this formula is a Ctrl+Shift+Enter (CSE) formula.
When generating a document and then opening it, simple formulas (like '=SUM(A1:A2)') are evaluated. Users have nothing to deal with formulas, they just have to fill the cells.
However, I don't know how to make my CSE formula evaluated when opening. Right now, the formula is valid and correctly translated with localized functions' names, but users still have to evalute it manually by going on the cell, then in the formula bar and finally pressing Ctrl+Shift+Enter.
Isn't there any way to tell Excel, through PhpSpreadsheet, to evaluate this formula on opening?
As for example, here is my CSE formula:
=SUM(--(FREQUENCY(IF(E14:E25="CREDIT_CARD",MATCH(F14:F25,F14:F25,0)),ROW(F14:F25)-ROW(F14)+1)>0))

It seems PhpSpreadsheet can't do that right now, I don't know why.
There must be some complications about that.
But I found a pull request that fits my needs, by handling array formulas: https://github.com/PHPOffice/PhpSpreadsheet/pull/1591

Related

Nested Calculations

I'm trying to make a complicated formula display its calculated values in excel formula bar.
For example this =(D9* AE9)+(A9-E9) be displayed like this =(4*0.88)+(3-1).
I would really appreciate your help on this!
Thank you in advance
The Excel Formula Bar always show the formula in the active cell - you cannot use VBA to permanently change one without changing the other.
If you select a portion of the formula (a subexpression) in the formula bar and press F9 excel will show you the result of evaluating that subexpression (remember to press Escape to revert back to the formula).
If you are looking for a way of understanding/troubleshooting complex formulas try Excel's built-in Evaluate Formula tool on the Formulas tab.
There are also more powerful formula explorer addin tools available commercially. These use formula parsers and evaluaters to show the user what the parts of the formula resolve to.

excel formula sumif formula not calculating

I have used the sumif formula for many years but I find it is not working now. The report I have was first a text or pdf that was converted into an excel file. I have done the F9 key that did not work. I have checked the compatibility mode setting. The cells are number fields not text or general. I could use some expert advise how to make the formulas work.
Here is a screen shot of a sample page. The formula is in cell J6 thru J8, the formula in in the formula bar.
I think this is what you need:
=SUMIFS(C:C,A:A,I6,B:B,$J$5)
If this still gives you troubles go with:
=SUMIFS(C:C,A:A,"*"&I6&"*",B:B,"*"&$J$5&"*")
And to put it into perspective of your formula:
{=SUM(IF((A:A="*"&I6&"*")*(B:B="*"&$J$5&"*"),C:C))}

Excel to Google spreadsheet - formula conversion

I have the following formula that works out filtered by multiple conditions.
{=SUM(COUNTIFS('List'!$H:$H,TRANSPOSE('Assignee'!$C2:$C6), 'List'!$U:$U, 'Proceed'!$B2:$B8)))}
So I converted to google sheeets formula using ARRAYFORMULA Function for array-evaluated but it doesn't worked.
=ARRAYFORMULA(SUM(COUNTIFS('List'!$H:$H,TRANSPOSE('Assignee'!$C2:$C6), 'List'!$U:$U, 'Proceed'!$B2:$B8))))
I made a sample document. Open sheets
You can check a formula in the summary sheet.
How can I solve this?
It should work. Maybe you forgot to array-evaluate it?
Double click the cell and press Ctrl+Shift+Enter OR, wrap the whole formula with =ArrayFormula()
=ARRAYFORMULA(SUM(COUNTIFS('List'!$H:$H,TRANSPOSE('Assignee'!$C2:$C6), 'List'!$U:$U, 'Proceed'!$B2:$B8))))

Excel 2013 Forumla Not Working in some Cells

SO I'm trying to get some work done in Excel 2013, and after getting an initial formula to work, I dragged it across several other cells. I did all the standard locking of references and such, even copied the exact formula into the new cell formula window with copy paste. The formula works in the first cell, not in those it's dragged over. It also works in seemingly random cells when pasted around (see screen shot).
Formula is below... this was a brand new sheet, the cells had not been initialized until the formula was pasted. Is this an issue with Excel 2013? Since the formula works in some pastes perfectly, and not in others, I don't think that's the issue... I changed the cell format after the pastes in a couple cells to see if that changed results at all - it does not.
Update: I added in the false value, and the IF is evaluating to false on the zero cells... why it's correctly true in some, and false in others is still a mystery.
=MIN(IF('Metrics'!$DL$2:$DL$1725=$L$2&$O$2,'Metrics'!$DH$2:$DH$1725))
The issue is that for the formula to correctly evaluate it should be set as an array (ctrl-shift-enter).
However, Excel 2013 seems to randomly recognize the formula as an array formula, and sometimes not. Thus the formula occasionally will work, in a brand new, uninitialized cell, using/displaying the standard formula, and a correct result. Other times it will still display the same formula, but produce incorrect results since it is not being evaluated as an array.
Any of the cells that did not magically convert to an array formula, when changed to array, will update with correct values.
Only manually changed cells reflect the {=MIN(IF(...)...))} indication of an array formula. Cells in which the formula produced correct results still display as a non-array formula.
I had a similar if not exactly the same issue. Try hitting F9 to recalc the sheet, or go to File>Options, go to "Formulas" and under "Workbook Calculations" set it to "Automatic".
Solved my problem, which manifested the same way yours did.
Good luck!
Since you are,using $ sign to lock the cells in the formula, it looks like you are just pointing it to the same cells giving you same results... Click on the formula and check or change to the correct reference cells as you desire...
turns out my 2003 excel problem was due to some circular formulas. Had "Circular:" at the very bottom line. When these all fixed, the other cells started to calculate properly.

Dot product between row vectors by MMULT not working in Excel

I am using Excel to do some dot product between two row vectors:
=MMULT(B1049:M1049, TRANSPOSE(B1050:M1050))
But it does not work, as the cell for the formula shows "#VALUE!". I wonder why? Thanks!
Note that all the cells in "B1049:M1049" and "B1050:M1050" are numbers.
PS: Is this question more suitable here or Superuser?
probably simpler, you can just use =SUMPRODUCT(vec1,vec2).
This is exactly the Euclidean inner product, without resorting to array formulas.
you need to enter MMULT as an array formula, not as a standard formula
rather then hit enter when you type the formula in pres
ctrl-shift-enter
and excel will enter it as an array
it will end up looking like
{=MMULT(B1049:M1049, TRANSPOSE(B1050:M1050))}
(please note you can't enter the {} manually)
You may want to look at Excel help which covers this well

Resources