I'm sure this is an elementary answer but I cannot see the forest for the trees at the moment, any help would be appreciated.
I'm building a query in which I need to have the results fill TRUE if there is any filled value in the table that is queried.
One approach is that you convert the field your checking into a 1 or 0 based on whether it contains data or not.
So a table:
ID, Field1
1 , "A"
2 , ""
3 , "C"
You could then have a query:
SELECT Sum(IIf(Len(Trim([Field1]))>0,1,0)) AS CompletedFields FROM Table1;
Which will give you a count of the completed fields, in this case 2, which will equate to True as boolean.
Obviously you need to adjust the Len(Trim([field]))>0 to match your rule that determines if a field is complete or not.
This also gives the actual number of completed (and therefore uncompleted) rows, rather than a blunt true/false.
Related
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.
I am using Dojo DataGrid with dojo 'AndOrReadStore' so that I can use complex queries on column data.
I have a column, say DocumentTypeIds, in dojo DataGrid that shows comma seperated string of type ids of a document for each document row. Lets say its value is '5, 6' among 20 different possible values. These document types are further categorized into 3 categories: A, B, C. for example
Document Type/name | A B C
---------------------------
5 / finance report | 1 0 0
6 / summary report | 0 1 0
Based on choice of A, B and C, I want to filter documents in the grid. For example if user chose C and document type ids are '5,6' then I do not want to filter this document. I can filter the possible document type ids based on category in an array that I want to compare this column against. Lets assume the possible values after choosing option C are [8, 9, 2, 99] then my filtering condition needs to be
[5,6] in [8,9,2,99]
or
'5,6' in '8,9,2,99'
The problem with first approach is that column values are in CSV format so i dont think i can convert those into array in query. The problem with second approach is that i dont want to find string '5,6' in '8,9,2,99' rather i want to find if both '5' and '6' exist in the '8,9,2,99' and they may not appear next to each other in '8,9,2,99'.
I don't know how to approach this problem as it is very important for me to filter the rows at client side because I want to bring in all rows and let user choose what type of documents they want to see.
grid.filter({complexQuery: "DocumentTypeIds: ? "});
I appreciate any help.
Thanks
How can I get all 3 values from a Map with the key "2" ?
Right now it takes always the last one from any number, for example if i type in "1" it will take the last letter of it "f".
Is it because there is no loop ?
AFAIK, it is not possible to directly store multiple values with the same key in Stencyl, nor in any programming language. Each value will overwrite the previous one, which is why your 2 key is returning i. Instead, you could consider these workarounds:
Name your keys 0a, 0b, 0c, 1a, 1b, 1c, and so on. It's pretty simple to get the values with this method.
Store your values in a single key, separated by commas. E.g. key 0 is a,b,c, 1 is d,e,f, and so on. Then you can use the list blocks with split (value of 0 for TT) using separator , to get the 3 values (which will be a, b and c).
If you have any questions about either of these methods, don't hesitate to ask!
Select sum(a),sum(b)
from table
where c like '234%'
and time > '2013-12-31'
and d = 'hello';
Then I explicitly calculate the value of sum(a)-sum(b).
Select sum(a-b)
from table
where c like '234%'
and time > '2013-12-31'
and d = 'hello';
As both of these queries are giving different results.
By Doing an EXPLAIN ANALYSE on both of these queries, I see that second query has removed more rows by Filter conditions.
I am not able to find an explanation for this.
The difference is likely due to nulls existing within the data. If you had "a" as 3 and "b" as null then you'd receive a null result on something like:
select 3 - null;
Doing the sums individually will allow each to increment to the actual sums skipping nulls only for that individual column not the entire row and likely be more of what you're looking for.
Is there a logical reason why the following statement from the Hyperspec is the way it is?
"If there is a duplication between list-1 and list-2, only one of the duplicate instances will be in the result. If either list-1 or list-2 has duplicate entries within it, the redundant entries might or might not appear in the result."
Until I read this I was assuming that union should return a unique list and frustrated why my code didn't do so. It also seems odd to remove duplicates between lists but not within. Why even specify this?
It seems like one should be able to assume union will produce a unique list of the set's elements or am I missing something?
For the full page in Hyperspec see http://clhs.lisp.se/Body/f_unionc.htm
If your code has sets only with unique elements (like 1 2 3 ), then UNION will preserve this property.
If your code has sets with non-unique elements (like 1 2 2 3 ), then UNION does not need to make any effort to enforce uniqueness in the result set.
Removing duplicates is done with a separate function: REMOVE-DUPLICATES.
Assuming that elements of both lists that are arguments to UNION are unique means that the complexity of the algorithm in the worst case (non-sortable, non-hashable elements) is O(n*m). On the other hand removing duplicates in a list in that case is O(n^2). Making UNION remove duplicates would approximately triple the running time even in the case where there were no duplicates, since most of the time is consumed by doing the comparisons.