I have a domino view with an amount column but some values are empty...and need to be. The problem is that the #Sum works fine until I have an empty value then it stops summing.
eg: if the values are 5,5,"" and 5 I get a sum of 10 and not 15.
I've traced the problem to the #DbLookup which is that it stops building the return array when it encounters a blank value. There is no built in method of dealing with null values.
https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/reference/r_wpdr_atfunctions_dblookup_r.html
To make things harder, #dbLookup returns a string if only one is found or an array if more than one are found. If the values are 5,5,"" and 5 it returns an array of 2 values.
var alloc = #Sum(#DbLookup(#DbName(), "SubForms",MainFrmID , "ca_ca_ca_ca_amount"));
if (isNaN(alloc)){
return "$0.00";
}else{
return "$" + alloc.toFixed(2);
}
Can anyone help me refactor the #sum or #DbLookup to allow for empty values? Unfortunately I cannot define any new functions for this solution. The environment is locked down tightly. With a list of values of 5,5,"" and 5 I need a sum of 15.
I would try #Sum(#TextToNumber(#Trim(#Text(#DbLookup(...)))))
I would try
#Sum( #Transform( #Dblookup ( ....
If #DbLookup does not do what you need, you could always iterate over documents or view entries to build the sum.
The flow would be roughly like this:
1. Get a handle to the current database.
2. Get a handle to the "SubForms" view.
3a. Get a view entry collection using using getAllEntriesByKey() with MainFrmID as key, if a view column exists that displays the values you need.
--OR--
3b. Get a document collection using getAllDocumentsByKey() with MainFrmID as key, if no view column exists that displays the values you need.
4. Iterate over the collection to sum up values, using getColumnValues().get(columnNumber) to access the value from each view entry, or getItemValueDouble(fieldName) to access the value from each document.
That way you can easily detect null values and discard them.
Related
I have a value that I need to compare to the values in an object. The object is like:
[{"dbid":800,"MemberID":1460,"ID":1460,"Search":"TRUE","Year_Start":"2017","Year_End":2019,"Last_Name":"XXXX","First_Name":"XXX","Middle_Initial":"X","Suffix":"","Email":"","Program_Code":"CM","Pending":"","Initials":"OS","Include":"1","Exclude":"0","Authoring_Names":""}, ... ]
and again for 100's of names.
I want to create a search box that allows the end user to compare a name to the names in the list. So I want to send the last name of the comparing value to a function that will return most of the information such as First Name, Middle Initial, Last name, Program etc. The comparing value may or may not be in the list.
I've look at
Vue JS2 find array value by id
and it's close, but I want more information than one element. Also I saw that it maybe possible to filter an object in Veux, since I store that information in there.
To find all people with a certain last name, you should use filter as it's very similar to find only it returns multiple items in an array.
const found = people.filter(({ Last_Name }) => person.Last_Name == Last_Name);
Note that to check if no people have been found you need to check if length == 0 because an empty array is still truthy.
I have a dropdown of country on a webpage. I need to validate the country names in drop down is sorted using Protractor-Cucumber.
I located all options in dropdown using element.all() and used a forEach loop on array. For each iteration, it extract the text and add to another array. Since extracting text takes some time, my resultant array does not have texts in same order as it appears in drop down.
element.all(by.css('ul.sbsb_b')).then(function(allOptions){
allOptions.forEach(function(optn){
optn.getText().then(function(text){
result.push(text);
})
})
});
If my dropdown contains options as A,B,C,D then resultant array should give me in same order. Above logic works fine for less number of options. I want forEach to do iteration one by one instead of all at once because of asynchronous nature.
The method I would attempt for this issue would be to convert your ElementArrayFinder into an array of strings directly using .getText(). I would imagine this would preserve the order but cannot say for sure.
element.all(by.css('ul.sbsb_b')).getText().then(function(allOptions){
console.log(typeof allOptions)
console.log(Array.isArray(allOptions))
}
To preform your validation there are two approaches you could take which do not require any particular order of the state names array you are extracting.
You could sort the array and then expect them both to be equal.
element.all(by.css('ul.sbsb_b')).getText().then(function(allOptions){
expect(allOptions.sort()).toEqual(expectedStates);
}
Or you could validate that the array you have created is the same length as your expected array of states and then verify that every expected state appears at least once in the created array
element.all(by.css('ul.sbsb_b')).getText().then(function(allOptions){
expect(allOptions.length).toBe(expectedStates.length);
for(let i = 0; i < expectedStates.length; count++){
expect(allOptions).toContain(expectedStates[i]);
}
}
In my Angular app I'm returning results via an API call, and allowing users to filter those results through a series of checkbox selections. Right now I'm running into an issue where, while results are returned as expected when one value is sent for a certain filter, when multiple values are selected (like filtering by more than one zipcode, for instance) I get zero results printed to the view. No errors, just no results.
After scratching my head for a while, using Chrome devtools network tab, I finally determined that the problem is that rather than wrapping each item in quotes in the payload - like this: "90001", "90002", what's being sent is this: "90001, 90002". In other words, quotes are wrapped around as if it were one value, not two.
This is the code, where I'm using a "join" to put together the values that are selected:
this.sendZipcode.emit(this.zipcodeFilters.text = arr.length === 0 ? undefined : arr.join(','));
I'm not sure how I can adjust the way this "join" is constructed, or find some other solution instead of "join", in order to have each item wrapped in quotes, rather than wrapped like one long string.
FYI, this is what I see in the network tab of Chrome devtools after selecting two zipcodes. As I explained, it's wrapped like one string, rather than as two values:
addresses.zipCode: {$in: ["90001, 90002"]}
Array.prototype.join will return a string. So you are converting your array to a single string which is being sent as a string. You want to send an array. Simply remove the join call and return arr directly.
String: "value, value"
Array: "value", "value"
I've been having issues with a synchronized arrays on angularfire. I'm on angularfire 1.1.3 with firebase 2.3.1.
I have a query
var arr = $firebaseArray(ref.limitToFirst(5));
and the behavior I've seen up until now is that when I call
arr.$remove(0)
the next object that would be returned by the query gets loaded into the synchronized array automatically. This essentially makes the array a sliding window over the query response - it always has the same number of elements.
Since last week, that behavior seems to have changed, and I get two different cases:
1: Either arr does get loaded with 5 items, but after calling arr.$remove five times, the array is empty - which would be normal behavior on a JavaScript array, but isn't what I'd been seeing before on an AngularFire synchronized array.
2: Or arr is loaded but then disappears, i.e. in the code:
arr.$loaded(function(){
\\ break
})
If I break in the call back, arr does have five items, corresponding to data on Firebase, but at the end of the Angular digest loop, arr is an empty array.
Demo: This plunker shows behavior 1
So my questions are:
Was I relying on a behavior that was not officially part of the API?
Has that behavior changed?
What explains the last point (the firebase array having items on $loaded but then ending up empty?)
Update
It seems that behavior 2 happens after behavior 1 - more precisely: after getting to an empty synchronized array, if I reload the page, then I get a nonempty array in the callback of arr.$loaded but an empty array in the end.
Could that mean that firebase itself gets "stuck"?
I'll try to to reproduce that in the plunker.
This should be fixed now. Sorry for the inconvenience!
I have a table (in a RethinkDB database) that has a bunch of documents with the field VIN0. This field almost always stores numbers, as intended.
I had some data corruption recently where there are some strings in place of numbers for the field VIN0. Queries I was using to manipulate this data now return the error: "e: Expected type NUMBER but found STRING in:"
I'd like to filter for the strings, but I can't seem to find them. Is there a way to use something like Number.isInteger() to filter out these items within RethinkDB?
Thanks!
You can use typeOf to find type of a field, or a element. Let's say you want to filter document with VIN0 is a number
r.db('db').table('table').filter(r.row('VIN0').typeOf().eq('NUMBER'))
You can also try to correct problem by using coereTo to convert string to number.
r.db('db').table('table')
.filter(r.row('VIN0').typeOf().eq('STRING'))
.update({VIN0: r.row('VIN0').coerceTo('NUMBER')})
Hope this helps.