How to count unique occurrences with criteria in excel - arrays

I'm using the below array formula to count the unique occurrences of text in column C using the agent name in column G as the reference. This is giving me multiple issues.
=SUM( --(FREQUENCY(IF(G3:G100000 = J5,MATCH(C3:C100000,C3:C100000,0)),ROW(C3:C100000) - ROW(C3) + 1) > 0))
Depending on the data set I'm using multiple agents will return a #N/A result and I can't figure out why.
Each dataset I'm using is 20k to 30k lines, so the formulas take a long time to process.
Any ideas how I could do this faster or better? Also any ideas why some agents get bad returns?

I am assuming that you are looking for the number of unique combinations of columns C and G.
Create a pivot table and check the box to add this data to the data model.
Drag both column headers to the Rows section, also drag one (of those same two) into the the values section.
click on the the field in the values section > value field settings > summarize values by > choose Distinct Count. This removes all duplicates.
Click the Row Labels filter and uncheck the blanks.
You can drop in new data then right-click on the pivot and refresh to see the new results. See the image.

Related

Long calculation times with XLOOKUP vs INDEX-MIN-COLUMN

I'm using this formula =IF(B24="","",IFERROR(INDEX(Sheet3!$C$3:$EE$3,,MIN(IF(Sheet3!$C$4:$EE$23=(Sheet2!C24&$K$18),COLUMN(Sheet3!$C:$EE)))-2),"NF")) to return a cell value in the top row of an array - a date in this case.
The search criteria is a combination of a unique project number and a 2 digit status alphanumerical code for the project. The array consists of 23 rows where combinations of the unique numbers are found, each with different status codes.
So essentially, I'm building a FILTERED project status dashboard that returns dates linked to the relevant project status.
The code above is inspired from ( LINK ) that uses a very similar layout, but it uses town suburbs linked to postal codes instead of project numbers and status codes. The formula works well (though, not entered as an array formula), but I don't have a single formula in the sheet, I have 3 300 occurrences of this formula.
The problem comes in when the user changes the FILTER - Excel recalculates the entire dashboard and that takes anywhere from 2 to 5 minutes to run. You hit the escape button and cancel the calculation after setting the filter, but Excel just starts calculating again after a few seconds. After that, Excel's response is sluggish and almost unusable. Yes - our hardware is pretty weak ...
I tried XLOOKUP as well, but can't set the "lookup_array" to an array ( Sheet3!$C$4:$EE$23 ) because it doesn't match the "return-array" ( Sheet3!$C$3:$EE$3 ) Concatenating the lookup arrays with & works, but then you'd have to do that for all 23 rows, and again, multiply that by 3 300.
I thought of creating a UDF, but the function will still be called every time Excel recalculates after filtering... 3 300 calls ...
Any ideas on how to make the INDEX version run faster, or make the XLOOKUP accept the lookup_array as Sheet3!$C$4:$EE$23 in the hopes that it'll run faster?
Thank you!
Not really an elegant solution, but it works.
I imported the dataset into a helper sheet, where I combined the cell value with the corresponding value in Column A for each row ( a name in this case ) and the date from row 1 for each column, using underscore as a delimiter.
This new data range was then given a unique name, EE in this case.
On a second helper sheet, using this formula =INDEX(Filtered,1+INT((ROW('Sheet1'!C3)-1)/COLUMNS(Filtered)),MOD(ROW('Sheet1'!C3)-1+COLUMNS(Filtered),COLUMNS(Filtered))+1) and drag it down till it returns an REF! error and going back one row before the error.
This transposes all the data into a single column G. Using =UNIQUE(SORT(FILTER(B3:B3240,B3:B3240<> "",""))) then gives me a filtered list of unique values in column H that I then run
=IF(H3="","",LEFT(H3, SEARCH("_",H3,1)-1)) for the first data value in I, and
=IF(H3="","",MID(H3, SEARCH("_",H3) + 1, SEARCH("_",H3,SEARCH("_",H3)+1) - SEARCH("_",H3) - 1)) for the middle data value in J, and
=IF(H3="","",IFERROR(TEXT(RIGHT(H3,5),"yyyy-mm-dd"),"NF")) for the last data value in K.
Then just run XLOOPUP across columns I, J and K.
Runs quick and easy and solves a few of the other issue I had as well.
The second data set has just over 35 000 rows - still works well and fast.

Link two cells in google sheets with autofill

First of all I would like to thank you for your time.
I have a google data studio report that extracts data from a google sheet. The data studio sheet gets values from a google form (in the form of another tab in the sheet). Altough the cells are linked, right now I have to drag the cells in the data studio sheet to pull the values from the forms sheet. If there are no values it can´t pull anything and I would like to have real time values in the google data studio as soon as a form is filled.
Right now all I have is a simple (='Form '!C55) to pull. What I would like to do is if there is a new value in the following cell in the forms sheets then the following cell in the data studio sheets pulls it so it can go to the report in dat studio.
Cheers to all!
Try this formula, in column A, after your last row of good data. So perhaps in Dados!A91. Note you will need to first delete everything in all of the cells below and to the right of A91, since this formula is filling everything:
=QUERY('Formulário '!A9:O;"select A,G,D,J,M,H,E,K,N,I,F,L,O where B <> '' ";0)
This queries your Formulário sheet, and pulls all of the data starting in row 9 (since that is what you were showing with your formula before), and selects all of the correct columns in order.
Please test it out with a test form submission, to see that it works as expected, and that it is copying the correct columns, in the right order. Let me know of any questions or issues.
I'm not positive how sheet updates work when there is no active user logged into the sheet, but I suppose when Data Studio goes to pull from Dados, it will first ensure that it has the latest data from all formulas.
Update
To have the Max and Min values,which you say should be the same all the way down the column, add a formula like the following in the header row (row 1) of your Formulario sheet:
={"Cloro Max.";ArrayFormula(IF(LEN(A2:A);1,5;""))}
That gives a value of 1,5 for a column labelled Cloro Max. Be sure to delete anything from row 2 down, in that same column, or the array formula gives a #REF error, since it can't put data when there is already data entered in those lower cells.
You can change the text to create a Max or Min column for each value you want, in columns Q to V. Change the 1,5 to whatever number you want, such as 0,5 for Cloro Min.
It will always add the value(s) to each new row as it gets added from a submitted form response.

Vlookup from multiple criteria to display nearest answer

I was hoping someone can help me. I have hit a solid wall.
I have a table with product information included and I am building a calculator which should spit out a number of options based on set criteria which is in the table. I am failing at just pulling through a code. I feel rather embarassed asking about how to do a vlookup here. But basically I have a vlookup which depends on multiple criteria and for the calc to cough out the nearest match (if applicable) based on this criteria.
Criteria 1 = Product
Criteria 2 = Type
Criteria 3 = Height
Criteria 4 = Min
I have created a search key in the table to concatenate all of these columns and then done a vlookup, which is =Vlookup(Criteria1 & Criteria2 & Criteria3 & Criteria4, Table Data, Code Required) But this does not appear to be giving me results, it either coughs out an error or the incorrect product. Below is my data and my calc I am hoping to complete. Can someone please help?
Here is an example looking for a closest match on Min. It demonstrates the principle so you can extend.
The closest match formula part is:
MATCH(MIN(ABS(E2:E4-K2)),ABS(E2:E4-K2),0))
Column E for column with Min values in. And K2 for target Min. This is an array formula entered with Ctrl + Shift+Enter. You would adjust the range of E2:E4.
The multiple criteria part is using:
=MATCH(lookup_value_1&lookup_value_2&lookup_value_3, lookup_array_1&lookup_array_2&lookup_array_3, match_type)
Where you are concantenating your parameters and searching for a match of the concatenation of those parameters in the table (you could do this against the key column if the key is made up of the same parameters.)
Overall formula with some test data (using one estimate figure):
=INDEX(F:F,MATCH(K1&K5&J5&INDEX(E2:E4,MATCH(MIN(ABS(E2:E4-K2)),ABS(E2:E4-K2),0)),B:B&C:C&D:D&E:E,0))
Above entered combined formula remember is an array formula so entered with Ctrl+Shift+Enter . You can reduce the ranges from entire columns to only those rows holding data.
Data data:
I am not typing all that out from picture so here is a quick n dirty
I tried with the QHarr's solution but it didn't work with all the rows.
My solution is:
Add a column with:
=IF(E2 < $K$2, E2, 0) and copy for all rows
In L5 create the formula:
{=INDEX(F2:F19,MATCH($K$1&K5&$J$5&INDEX(E2:E19,MATCH(MAX(SI(B2:B19=$K$1,1,0)*IF(C2:C19=K5,1,0)*IF(D2:D19=$J$5,1,0)*G2:G19,0),E2:E19,0)),B2:B19&C2:C19&D2:D19&E2:E19,0))}
Copy the formula to L6 and L7
Excel exercise printscreen
Originally marked this as answered and it did work initially but as I added more products it began to fail. I did manage to (after much trial and error) find a simple solution {=INDEX(Calc!$I$2:$I$189,MATCH(Output!$H$7,IF(Calc!$B$2:$B$189=Output!A12,Calc!$H$2:$H$189),1))}

Limit text in SSRS Report Table

Background:
I have a table with say 40 columns reporting Employee Details. Where 39 of 40 columns are of Datatype varchar(10) and the 40th column, being Manager's comments, is of Datatype varchar(1000).
Problem:
The report is looking bad as due to one column the height of the complete row is increasing than normal expectation.
Solutions I thought of:
Increase width of column > Looking bad if no comments
SubString the data coming > Loss of data
Set CanGrow to False + set the Height for Row to have 2 data lines + Show text on tool tip + Export to excel link of a different report which has CanGrow as false > not very good solution
Can someone suggest a better way to handle one column with more text than the rest of them as even my 3rd approach is looking non-ideal to me?
Thanks in advance.
A little unconventional, but in situations like this I've put the last column in its own row beneath the other columns, merged all the cells in that row, and then grouped by the primary key. That makes a report in which you've got a two row SSRS group for each row in your query results, the first row contains all of the short columns and the second row contains just one long column. If there is a fairly short string in that last column, or an empty value, it will just take up one row. If there is a long string, then it will have space to expand vertically (if CanGrow=True), instead of expanding horizontally and making an impractically long report.
This may not meet all reporting purposes, but if the report is intended for visual use it can work well.
The best solution I could find was
Set CanGrow = False
Increase Width and set a generic Height
Show tooltip
Export to excel works fine and shows data unlike I expected (as the data is not truncated but just the textbox is restricted to show data in SSRS frontend)
This works for me as there is no data loss.

Add each row in a single cell

I have a requirement in ssrs report for display data like this.
I have to show 2 two rows data in one row in ssrs as shown below. Row count is unknown.
Please check another example.
Max two cell in one row in ssrs. I have to do this dynamically because I don't have any fix count in my data base table. If my table contain 3 rows it will display like first example but it it has 6 rows then it will looks like 2nd example.
Any suggestion how I can achieve.
The only way I know to do this left-to-right, top-to-bottom flow style is to sort of hack it in with lists. To my knowledge, the built-in controls do not directly support it.
First add a couple of columns to the query output to assign row and column numbers to each data row. (Change the order by clause as appropriate)
ceiling(row_number() over (order by AddressField) / 2.0) RowNumber
(row_number() over (order by AddressField) + 1) % 2 + 1 ColumnNumber
Now add a list to the report. Group by the RowNumber field. Within that list, add two more lists side by side. They will use the same dataset as the parent list. These will represent the cells. The left 'cell' will be a list with a filter ColumnNumber = 1. The right 'cell' will be a list with filter ColumnNumber = 2.
Now add textboxes within each 'cell' to contain the address data and format them as you desire.

Resources