With my previous posts
1. PHPSpreadsheet generates an error "Wrong number of arguments for INDEX() function: 5 given, between 1 and 4 expected"
2. Excel - Getting the Top 5 data of a column and their matching title but produces duplicates
I have found out that the PHPSpreadsheet library for PHP is yet to allow the usage of the AGGREGATE() and complicated formulas/functions but I'm in dire need of their functionalities
Going back, I have 2 columns in my Excel (produced by my web applications made from CodeIgniter and Laravel)
The problem is, the Article Count column (on the right) contains 2 values of 54 which is supposed to belong to 2 different Publications (on the left) but with the use of the formula =INDEX(E$4:E$38,MATCH(M4,J$4:J$38,0)) it just fetches the 1st matched Publication.
The output should look like this:
The original Table:
My question is, what would be the right function or code in Excel so I could retrieve the SECOND Publication of my matched data?
I'm aiming to target those Publications that has the Article Count of 54, but I want to aim the SECOND ONE which is the letter D WITHOUT using the Aggregate() function of Excel
Here are my used codes
1) =LARGE(J4:J38,1) - J4:J38 is my range of raw data, I am using this to get the 5 highest numbers in descending order
2) =INDEX(E4:E38,MATCH(M4,J4:J38,0)) - I'm using this to retrieve the Publication Names that matched the Article Count
After communicating in chat, we got this correct formula:
=INDEX(E$2:E$38,IF(M4=M3,MATCH(L3,E$2:E$38,0),0)+MATCH(M4,OFFSET(J$2,IF(M4=M3,MATCH(L3,E$2:E$38,0),0),0,COUNT(J$2:J$38)-IF(M4=M3,MATCH(L3,E$2:E$38,0),0),1),0))
How this works:
This IF(M4=M3,MATCH(L3,E$2:E$38,0),0) returns the position of the previous row's publication title in the titles array (E), in case the current publication count is the same with the previous one. Let's call this number X. Instead of using J2:J38 for the results, we use J(2+X):J38. This trick is done by using offset to cut off the previous section, already used by the previous row. This way, on repeating publication counts the already mentioned titles get ignored.
You need to use AGGREGATE's SMALL sub-function to return the smallest matching row number and adjust the k argument to accommodate duplicate rankings.
'in M4
=LARGE(J$4:J$38, ROW(1:1))
'in L4
=INDEX(I:I, AGGREGATE(15, 7, ROW($4:$38)/(J$4:J$38=M4), COUNTIF(M$4:M4, M4)))
enter image description here
I am completely perplexed as to how to do what I am attempting to do.
I have an mysql array of various numbers selected based on username. Each user will have different numbers. So an example of output would look similar to:
13
23
47
79
150
216
Again array is completely different and based entirely upon username. I am trying to determine how to get the number from the row before and the row after when I know a given number.
So for example if I know that one of the results in the array is 79, how would I determine the result before and the result after? Mind you I don't know number 79 is row 4, and I don't know the number before it is 47 nor do I know the number after is 150.
How could I get the results of the row before and after a given number?
Please avoid PDO answers if possible as I am just learning and mixing PDO and non-PDO code seems to create issues whenever I try.
This was one of those issues where I spent to long programming and I was overlooking the logical answer.
Logically I need to set a loop counter on the original array so that not only the number is returned, but also the row containing said number. If I knew that the number is 79, I should have also been able to determine that it was row 4, and because of that, set a variable for row 3 and row 5.
So the simple stupid answer to my retarded question was, use a loop counter when determining the number. :)
I am a little new to MYSQL and PHP so any help is much appreciated. I have a database right now that is storing ten values, a name and 9 scores. I also have an excel spreadsheet that has the names and empty slots for those 9 scores. I have a bunch of formulas that use those 9 scores to calculate other scores. Is it possible to read those 9 scores for each individual name from my database then place them into that specific slot of the spread sheet based on there name? I do not want to write to a new spread sheet but rather input these scores into that spreadsheet that is being used. Thanks in advance!
In PhpMyAdmin select your database, then export -> CSV or CSV for MS Excel
Take a look at the screenshot:
I am using PHPExcel to write an entire array to a sheet and a couple of my columns need to have the value in every cell displayed as a percent (ie with the percent sign).
My problem is that when I try to format column G as a percentage with this code:
$format_percent = array('code' => PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
$objWorksheet->getStyle("G2:G".$rc)->applyFromArray($format_percent);
The resulting file has all cells in column G still with the "General" number format...not formated as a percent as I had hoped.
NOTE: the $rc variable is storing the row count
Any ideas? Thanks in advance.
Think I figured it out. I was trying to apply the formatting to the whole column at once. That doesn't seem to work. I thought it would because I CAN apply formatting like Bold to the text or and entire row at once. However, when I did a test and applied the percent formatting to one cell, it worked fine. So now I have just decided to loop over all of my cells in my column and apply the formatting one at a time.
Hi i have a mysql database, in which i have two columns Year_from & Year_two.
what i am trying to do is find a way where i can show the dates that are missing as buttons, for example if year from is 2006 and year to is 2008, i of course want to show 2006, 2007 and 2008. is this possible, as there isn't the value of 2007 in the database.
I haven't worked on any code yet as i am not sure if this is possible, or how i would achieve it.
Any ideas would be appreciated.
Thanks
Use range($year_from, $year_to) to generate a list of all years. Compare that array with the one you got from the database using array_diff() and bold the missing ones.
This needs to be done in code.
Basically, you'll read a bunch of records from the database, iterate through an array of years you'd like to show and check (every iteration) if there is a matching record present in the result set.