PHPexcel formula cell getting overrided instead of replace on filter column - phpexcel

I am using PHPExcel_v1_8, I have implemented formula to some cells like following.
$objPHPExcel->getActiveSheet()->SetCellValue('G4','=SUBTOTAL(2,B6:B'.$row.')');
$objPHPExcel->getActiveSheet()->SetCellValue('H4','=ROUND(SUBTOTAL(9,Q6:Q'.$row.'),2)');
I also tried like
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6,4,'=SUBTOTAL(2,B6:B'.$row.')');
Here $row means total number of rows.
But when I filter any column then it append/override value of formula applied cell. Please see following filtered total row.
I want only latest value should in filtered total row means want to replace existing value. Right now, I am getting correct value but why it is overrided? Any suggestions what can be the solution?

You've actually discovered a genuine bug here.
I wasn't aware when I implemented the SUBTOTAL logic in PHPExcel that it only worked with visible rows, and ignored hidden rows. Can you please raise an issue on the github repo
However, reading through the MS Excel docs for SUBTOTAL, a function of 2 or 9 will return the result for all rows in the range (hidden or otherwise) while 102 or 109 will return the result only for visible rows

Related

Is there a way to extract a substring from a cell in OpenOffice Calc?

I have tens of thousands of rows of unstructured data in csv format. I need to extract certain product attributes from a long string of text. Given a set of acceptable attributes, if there is a match, I need it to fill in the cell with the match.
Example data:
"[ROOT];Earrings;Brands;Brands>JeweleryExchange;Earrings>Gender;Earrings>Gemstone;Earrings>Metal;Earrings>Occasion;Earrings>Style;Earrings>Gender>Women's;Earrings>Gemstone>Zircon;Earrings>Metal>White Gold;Earrings>Occasion>Just to say: I Love You;Earrings>Style>Drop/Dangle;Earrings>Style>Fashion;Not Visible;Gifts;Gifts>Price>$500 - $1000;Gifts>Shop>Earrings;Gifts>Occasion;Gifts>Occasion>Christmas;Gifts>Occasion>Just to say: I Love You;Gifts>For>Her"
Look up table of values:
Zircon, Diamond, Pearl, Ruby
Output:
Zircon
I tried using the VLOOKUP() function, but it needs to match an entire cell and works better for translating acronyms. Haven't really found a built in function that accomplishes what I need. The data is totally unstructured, and changes from row to row with no consistency even within variations of the same product. Does anyone have an idea how to do this?? Or how to write an OpenOffice Calc function to accomplish this? Also open to other better methods of doing this if anyone has any experience or ideas in how to approach this...
ok so I figured out how to do this on my own... I created many different columns, each with a keyword I was looking to extract as a header.
Spreadsheet solution for structured data extraction
Then I used this formula to extract the keywords into the correct row beneath the column header. =IF(ISERROR(SEARCH(CF$1,$D769)),"",CF$1) The Search function returns a number value for the position of a search string otherwise it produces an error. I use the iserror function to determine if there is an error condition, and the if statement in such a way that if there is an error, it leaves the cell blank, else it takes the value of the header. Had over 100 columns of specific information to extract, into one final column where I join all the previous cells in the row together for the final list. Worked like a charm. Recommend this approach to anyone who has to do a similar task.

Access 2010 Calculate Crash on column addition

I am doing a calculate field in a table in access 2010. A column being the total is adding up to 24 other columns. I either get no return or it will crash.
I have the following in the expression builder that gives no return
[Column1]+[Column2]+[Column3]+[Column4]+[Column5]... etc
If I add an = as below, access will crash.
=[Column1]+[Column2]+[Column3]+[Column4]+[Column5]... etc
Note, both do not literally include '... etc' I just did not want to clog up the question with the column names.
I would like this to return the values of the columns being added together and totaled up. What is missing or required for this?

Remove total value for one column in PowerBI

I have a table visualisation in PowerBI that sums the top 10 products sold by sales quantity. I have a calculated column which shows the rate of sale, using other fields from the data source:
(quantity / # stores with product) / weeks on sale
The ROS calculates correctly, but it still sums and appears in the total row.. The number of stores and number of weeks are set to 'Don't Summarize', but they still add together and give some meaningless number in the total row. If i set ROS to 'Don't Summarize', to remove the total row, the summing of the rest of the table and therefore the filter I have on top N by quantity drops out.
It is very frustrating! Is there an option somewhere to simply not display total for a field?? I don't want to remove the total row completely as the other fields (e.g. Qty, Value, Margin) are useful to see a sum of.. It seems very strange that it is so difficult to do something so minor..
Additional info:
Qty is a SUM field.
Stores is not summarized and simply refers to the average number of stores that stock that product over the weeks of the trading season
Weeks is not summarized.
Weeks is not summarized and refers to the weeks that have passed in the trading season.
Example data:
Item.......Qty......Stores.....Weeks....ROS
Itm1........600........390.........2............0.77
Itm2........444........461.........2............0.48
Itm3........348........440.........2............0.40
Total.....1,392.....1,291*......6*...........1.65*
Fields marked with a * are those where the sum is a meaningless figure unrelated to the data. I do not actually need Stores and Weeks to show in the table, so the fact that they sum does not matter. However, ROS is essential, but the sum part is totally irrelevant and I do not want it to show. Any ideas? I am open to the idea of using R to overcome the lack of flexibility in the standard tables although my knowledge in this area is fairly limited.
I suspect you've made a common mistake - using a Calculated Column for ROS where you should've used a Measure.
If you rebuild that calculation as a Measure, then you can wrap the HASONEVALUE function around it, with the objective of showing a blank when there are multiple Item values in context (the Total row).
Roughly the Measure formula would be:
ROS = IF ( HASONEVALUE ( Mytable[Item] ) , << calculation >> , BLANK() )
I would also replace your use of / with the DIVIDE function, to avoid divide by zero errors.
You can remove individual totals for columns in tables and matrix objects in a round-about way by using field formatting.
Click the object, go to formatting, click the field formatting accordion, select the column or columns you want to affect from the drop-down list, set the font color to white, set 'apply to values' to off, and set 'apply to totals' to on.
A bit tedious if you have many columns, but you will have, in affect, whited-out the column totals.
Heads up, you might still have a problem with exporting data, though.
Cheers
Click on the table -> Fields -> expand the value field you don't want to include -> Select "Don't Summarize." This will exclude it from the "Total" row.
select do not summarise option for those metrics which you dont want total
Select the table you want to change
In the Visualizations pane:
Go to Format,
Find the Field Formatting option,
Choose the field you don't want to summarize.
Turn off 'apply to header',
Turn off 'apply to values',
Turn ON 'apply to total',
Change the font color to white.

Grouping, missing data - Cognos Report Studio

In IBM Cognos Report Studio
I have a data structure like so, plain dump of the customer details:
Account|Type|Value
123-123| 19 |2000
123-123| 20 |2000
123-123| 21 |3000
If I remove the Type from my report I get:
Account|Value
123-123|2000
123-123|3000
It seems to have treated the two rows with an amount '2000' as some kind of duplicated amount and removed it from my report.
My assumption was that Cognos will aggregate the data automatically?
Account|Value
123-123|8000
I am lost on what it is doing. Any pointers? If it is not grouping it, I would at least expect 3 rows still
Account|Value
123-123|2000
123-123|2000
123-123|3000
In any case I would like to end up with 1 line. The behaviour I'm getting is something I can't figure out. Thanks for any help.
Gemmo
The 'Auto-group & Summarize' feature is the default on new queries. This will find all unique combinations of attributes and roll up all measures to these unique combinations.
There are three ways to disable auto-group & summarize behavior:
Explicitly turn it off at the query level
Include a grain-level unique column, e.g. a key, in the query
Not include any measures in the query
My guess is that your problem is #3. The [Value] column in your example has to have its 'Aggregate Function' set to an aggregate function or 'Automatic' for the auto-group behavior to work. It's possible that column's 'Aggregate Function' property is set to 'None'. This is the standard setting for an attribute value and would prevent the roll up from occurring.

BIRT, How to get Dataset Row Count using Javascript

How can I get Dataset Row Count from Javascript function in BIRT. I tried searching this in BIRT exchange, but the only solution offered there is to have a new dataset getting count of values of required data set. This wont suit my needs.
Is there any way to obtain it using dataset events.
An easy way would be to count dataset items in a report variable.
Declare a new variable in your report outline:
Reset it in beforeOpen script of the dataset (in case this dataset is invoked multiple times during report execution):
vars["items"]=0;
Increment the variable in onFetch script of the dataset:
vars["items"]++;
Use your variable in any expression. For example add a dynamic text element in report's body such:
"Items count="+vars["items"]
Important 1: This approach works if and only if the dataset is bound to at least one report element (a table, chart, data element, etc.). For example, it won't work if the dataset is only invoked to fill a list of selection choices of a report parameter.
Important 2: In the body of the report, this variable can only be used after the first report element using the relevant dataset, otherwise it won't be initialized
Dominique has a great answer; It is not clear to me from your question if this simpler solution might also meet your needs.
In your data set use a computed column with a value of '1', then sum the values.
You can write JS that only adds the value if specific criteria are met.
Or you can use an aggregation on your report to sum the values, which would be after any filters or groups are placed.
There is a simpler way if you use the row number in your tables footer:
In the 'Dynamic Text' element you can select:
Avilable Column Bindings > Table > RowNum
Add 1 as the index starts with 0.
You could also make a variable and then add to that for each row created in a table.
For example, in the Table-Detail script, set an onCreate event to check for a value in each row and if there is one to increase the row count. The following onCreate script would check if the row is empty. If the row is not empty, the script increases the counter and goes to the next row.
var checker = this.getRowData().getExpressionCount();
if( checker > 0 ) vars["Counter"]++;
Then you could add dynamic text after the table with the following expression:
"Row count="+vars["Counter"]

Resources