I'm trying to use an expression in a Derived Column Transformation and it won't change from red, below is my code and I'm sure I have it correct, yet it keeps failing on me, any ideas why please?
(DT_WSTR,100,1252)([CategoryName]==''16-24s'' ? ''1'' :([CategoryName] ==''Boys''? ''2'':
([CategoryName] == ''Girls'' ? ''3'' :([CategoryName] == ''Groups'' ? ''4'' : ''5''))))
You need double quotes, not singles. If you let your mouse over over .... somewhere in that dialog box, you should get the error message
(DT_WSTR,100,1252)([CategoryName]=="16-24s" ? "1" :([CategoryName] =="Boys"? "2":
([CategoryName] == "Girls" ? "3" :([CategoryName] == "Groups" ? "4" : "5"))))
Related
I have body in html as:
<tbody [ngClass]="IsDisableRowSelectValidation == false ? 'row-select-validate' : ''" #formScroll [scrollTop]="formScroll.scrollHeight" *ngIf="PersonList">
Getting error as below:
Expression has changed after it was checked. Previous value: 'scrollTop: 128'. Current value: 'scrollTop: 0'.
I am not sure what is the cause of this error and how to prevent this kind of error.
I really appreciate the help. Thank you!
I'm actually making my discord bot and I wanted to make a command to know plane informations. I made it but know i want to put plane photos depending on the company.
I tried to do that:
if plane_data["data"][f"{flight_companie}"] == "FedEx" or "Ryanair" or "SWISS" or "Air France" or "SWISS" or "British Airways":
plane_photo = plane_data["data"][flight_companie]
else:
plane_photo = plane_data["data"]["unknown"]
Unknown is equal to a url photo that says there is no plane photos.
When i try with UPS it gives me that out:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'UPS Airlines'
Please help me out!!
if plane_data["data"][f"{flight_companie}"] == "FedEx" or "Ryanair"...
will always evaluate to True. This is because a string like "Ryanair" is truthy. Meaning it becomes true when converted to a boolean. So your line is equivialent to
if plane_data["data"][f"{flight_companie}"] == "FedEx" or True or True or True ...
or can not be used in this situation. I would use
if plane_data["data"][f"{flight_companie}"] in ["FedEx","Ryanair","SWISS","Air France","SWISS","British Airways"]:
instead.
I came accross a strange problem:
When I use a simple expression like:
=iif(Fields!Length.Value = "", "empty", Fields!Length.Value)
then everything works, and I get my value, or the word "empty" in my report.
If I would change my expression to a sum of 2 times the length, then my "empty" would still appear.
=iif(Fields!Length.Value = "", "empty", (Fields!Length.Value + Fields!Length.Value))
But when I multiply, then my "empty" goes to #Error, While the rest of the data works fine...
=iif(Fields!Length.Value = "", "empty", (Fields!Length.Value * Fields!Length.Value))
Any idea? I find this behavior very, very weird.
Your problem is that IIF evaluates both the true and false results everytime, even if the false result won't be used in the final output. So it's trying to do
'' * ''
when you value is an empty string.
You can fix this by using VAL which will return the numeric value of the string first, like this.
=IIF(Fields!Length.Value = "", "empty", (VAL(Fields!Length.Value) * VAL(Fields!Length.Value)))
SQL (Active column is of type bit):
id Question Active
1 Weather today 1
ASP.net Eval:
<img src='<%# Eval("Active") == "1" ? "images/active.png" : "images/inactive.png" %>' />
HTML:
<img src="images/inactive.png">
Why is the inactive.png image showing and not the active.
Bit fields correspond to boolean. Also you need to do a type conversion to ensure right comparison is done, as Eval outputs just object. So:
(bool)Eval("Active") == true
You could try to cast the result:
((int)Eval("Active")) == 1 ? [...]
or as mentioned in the comments to a bool:
((bool)Eval("Active")) == true ? [...]
Ahoy! I'm having a very funny issue with MongoDB and, possibly more in general, with JSON. Basically, I accidentally created some MongoDB documents whose subdocuments contain an empty key, e.g. (I stripped ObjectIDs to make the code look nicer):
{
"_id" : ObjectId("..."),
"stats" :
{
"violations" : 0,
"cost" : 170,
},
"parameters" :
{
"" : "../instances/comp/comp20.ectt",
"repetition" : 29,
"time" : 600000
},
"batch" : ObjectId("..."),
"system" : "Linux 3.5.0-27-generic",
"host" : "host3",
"date_started" : ISODate("2013-05-14T16:46:46.788Z"),
"date_stopped" : ISODate("2013-05-14T16:56:48.483Z"),
"copy" : false
}
Of course the problem is line:
"" : "../instances/comp/comp20.ectt"
since I cannot get back the value of the field. If I query using:
db.experiments.find({"batch": ObjectId("...")}, { "parameters.": 1 })
what I get is the full content of the parameters subdocument. My guess is that . is probably ignored if followed by an empty selector. From the JSON specification (15.12.*) it looks like empty keys are allowed. Do you have any ideas about how to solve that?
Is that a known behavior? Is there a use for that?
Update I tried to $rename the field, but that won't work, for the same reasons. Keys that end with . are not allowed.
Update filed issue on MongoDB issue tracker.
Thanks,
Tommaso
I have this same problem. You can select your sub-documents with something like this:
db.foo.find({"parameters.":{$exists:true}})
The dot at the end of "parameters" tells Mongo to look for an empty key in that sub-document. This works for me with Mongo 2.4.x.
Empty keys are not well supported by Mongo, I don't think they are officially supported, but you can insert data with them. So you shouldn't be using them and should find the place in your system where these keys are inserted and eliminate it.
I just checked the code and this does not currently seem possible for the reasons you mention. Since it is allowed to create documents with zero length field names I would consider this a bug. You can report it here : https://jira.mongodb.org
By the way, ironically you can query on it :
> db.c.save({a:{"":1}})
> db.c.save({a:{"":2}})
> db.c.find({"a.":1})
{ "_id" : ObjectId("519349da6bd8a34a4985520a"), "a" : { "" : 1 } }