I am confused.
I have a spreadsheet in google with 2 tables.
I want to select data from a sheet named "Presseverteiler" where a value in one field equals the value that I enter in a second sheet named "Veröffentlichungen". The formula is inside the sheet "Veröffentlichungen".
My code is this
=IF(not(isblank(D2)) ; QUERY(Presseverteiler!$A$2:AZ;"SELECT F WHERE A="&D2&" LIMIT 1"); "")
D2 is a number in "Veröffentlichungen" that equals a number in "Presseverteiler" in column A.
If the numbers in column A are not sorted from A to Z (1 to 510 in my case), the query yields the result I want.
If the numbers in column A are in order though, the query gives the result I want plus the entry of line 2 which it puts ahead of the result I want.
If I want entry 223 it would give 2 and then 223. To make it more weird: I have many other columns. Depending on if I sort those by A-Z or Z-A some of them give me 1 result in the query, some give me 2 results. Some give me 1 result both ways.
For example if I sort "title" A-Z (contains Mr, Mrs, Dr.) I get 2 results, if I sort the same column Z-A I get one result.
If I order the column "publication" A-Z or Z-A I get one result.
Despite all that, why does the LIMIT 1 not work here? Even with that I get a #REF! error that the results can not be displayed because they would overwrite successive fields in the table.
Related
I have a dataset that I need to arrange into a grid on a page (export to pdfs) as a customer report. Each row in my dataset needs to display as a cell. Each page would have roughly 3 records displayed as columns and then 4 rows of records. e.g. a (3x4 grid), being 12 records per page.
Right now I am using a matrix to display my results, but I cannot find how to get my matrix to start a 2nd row after 3 columns are generated.
Is this feasible or should I find a different solution to create these reports?
I was thinking may be if I had row groups to use, but not sure how to create a column that creates a repeating result 3 times then adds 1 to the next 3 results in my query. 111,222,333,444 and that could be my row grouping?
Here's what I use in a matrix to create a grid of columns from a single cell.
Add a ROW_NUMBER field to the dataset query and subtract 1 with the ORDER BY using the field to be ordered by.
ROW_NUMBER()OVER(ORDER BY DISPLAY_NAME) - 1 AS ROW_NUM
Add Calculated Fields to the dataset using the ROW_NUM.
Call the first COLUMN and MOD row_num by 3 to get values or 0 - 2 for the column number:
=Fields!ROW_NUM.Value MOD 3
Call the second calculated field ROW and get the INT of ROW_NUM divided by 3 to get the row number for the record:
=INT(Fields!ROW_NUM.Value / 3)
Then the matrix would have the Column grouping (and sorting) based on the COLUMN field and the Row grouping on the ROW field.
You could use a parameter as the number of columns (3) to make it easy to change.
So let's say I have 2 items in column A and 10 items in Column B. Is there a simple formula/script to output all the the probabilities of joining them?!
The output would be 2*10= 20 results
Thanks
EXAMPLE SCREENSHOT:
https://gmkr.io/s/59563cd5e76ce8393bee7c17/0
Something like this?
=arrayformula(row(indirect("1:"&count(A:A)*count(B:B)))^0/(count(A:A)*count(B:B)))
Starting with two items in column A and ten in column B, this will give you a column containing 0.05 repeated 20 times. Replace count with counta if the items are not numeric.
Here's the final answer:
=IF(ROW()-ROW($C$2)+1>COUNTA($A$2:$A$41)*COUNTA($B$2:$B$301),"",INDEX($A$2:$A$41,INT((ROW()-ROW($C$2))/COUNTA($B$2:$B$301)+1))&" "&INDEX($B$2:$B$301,MOD(ROW()-ROW($C$2),COUNTA($B$2:$B$301))+1))
FINAL OUPUT IMAGE
Its little complicated query as it contains some conditions.
I have tables like this:
table DC - which contains one row for one northing-easting pair
Columns - Id Northing Easting
PossibleValues - Guid Std value Std value
table DCR - which contains multiple rows for each row in DC. Each row here corresponds to data on each pass on that exact location.
Columns - Id VibStatus DrivingDir CompactionValue UtcDate
PossibleValues - Guid 0/1 Forward/Reverse/Neutral +ve integers Timestamp
table DCMappings - which contains mapping between both tables.
DCId DCRId
The output I need should contain fields like this:
ResultTable
DCId DCRId Northing Easting VibStatus DrivingDir CompValue Position CompProgress
Here, Position is its position in chronological order when sorted by UtcDate grouped by DC.Id(See query at end to understand more).
And CompProgress has some conditions which is making it complicated.
CompProgress is percentage increase/decrease in CompValue compared to its previous row which was in same driving direction when arranged in ASC order of UtcDate(chronological) where the rows to be considered here should only be the ones with VibStatus set to ON(1) grouped by DCId's.
Each row in DC has multiple rows in DCR. So if row 1 in DC has 10 rows in DCR, the CompProgress should consider these 10 rows alone for calculation and then for row 2 in DC, etc...
I have written following query to extract needed fields except calculation of CompProgress. Please help me in this.
SELECT DC.Id, DCR.Id, Northing, Easting, VibStatus, DrivingDir, CompValue, ROW_NUMBER() OVER (PARTITION By dcm."DCId" ORDER BY dcr."UtcDate") as passNo
FROM "DCR" dcr LEFT JOIN "DCMappings" dcm ON "Id" = dcm."DCRId"
LEFT JOIN "DC" dc ON dc."Id" = dcm."DCId"
Need evaluation of CompProgress in this query.
Sorry for lot of text. But it was necessary to make others understand what is needed.
How do I group/filter rows and then get total rows for each column. I am going to diagram what the result should be. I don't want to show the actual data. Just the count per column
Out Put should look like this
Column A Column B Column C
Row A - 235 records 300 records 15 records
Row B - 1 record 80 records 900 records
Each column represent a count on the same field but filtered.
So ..
Column A is really Count(MyColumn) WHERE = A
Column B is really Count(MyColumn) WHERE = B
To summarize each row is a grouping + filter and each column is a count based on the number of rows contained in that grouping. No row data needs to be displayed.
You can do this in a table in the group by using the following formula:
=SUM(IIF(Fields!MyColumn.Value = "A", 1, 0))
However, this type of summary report is what a matrix is designed to do. Use the Row field as the row group, the column field as the column group and a Count expression in the intersection and it will do it all for you.
I am trying to show the top 10 rows in my report. I can do this by setting the following expression for the Visibility of the row group:
=IIF(RowNumber(Nothing) <= 10, false, true)
and then sorting the table on the top numbers.
In my query I get two rows for each result, with different results. The problem is that I want to group these rows into one row in the report without losing the count for top X rows. But when I group on the name in my report in Visual Studio, it only shows every row one time and the count for X rows get incorrect. Sometimes I have the same name once and sometimes twice. I have tried to set the expression to 20 rows, but then I might get 12 rows sometimes and 10 rows sometimes, depending on how many rows for each name my query returns.
Thanks in advance,
Sara
It sounds like you need to top N after you group. Can you group in you query?