VB.net JSON If Using Textbox text in statment - json

Hi there im currently having an issue where the following code will work
If(jResults("items")("head") Is Nothing, "", jResults("items")("head")("icon").ToString())
however if i try to substitute a value with a textbox i cant get it to work
If(jResults("items")( + itemtypelbl.Text + ) Is Nothing, "", jResults("items") ("itemtypelbl.Text")("icon").ToString())
any help would be greatly appreciated

If your code is exactly as you have in your question, the problem is the lack of anything before the first + and after the second +. You need to have an operand either side of an operation like +.
EDIT: I also just saw that the name of the textbox should not be in quotes, as you are trying to access a variable property, not a hard-coded string.
Here is what I think your code should be:
If(jResults("items")(itemtypelbl.Text) Is Nothing, "", jResults("items") (itemtypelbl.Text)("icon").ToString())

Related

SSDT using multiple input fields in expression to create hyperlink

I am building an expression for a hyperlink in SSDT but I am trying to build it with 2 field inputs.
Here is what I started with in the expression box and it works.
="http://s1324.com/Report&Car=Toyota&Model=Celica"
Then i substituted Celica for &Fields!Model.Value and that URL worked. (where Fields!Model.Value = Celica)
="http://s1324.com/Report&Car=Toyota&Model="&Fields!Model.Value
Now i am trying to also substitute the word Toyota for a Car value (where Fields!Car.Value = Toyota) but i cant seem to complete the entire correct url
="http://s1324.com/Report&Car="&Fields!Car.Value"&Model="&Fields!Model.Value
Is there a way to use 2 inputs to create a URL?
Thanks
You've missed the ampersands in the middle part. Try this
="http://s1324.com/Report&Car=" & Fields!Car.Value & "&Model=" & Fields!Model.Value
If you put spaces between operators it's easier to read

SSRS "like" operator with nested iif

I have been trying to get a nested iif to work with the "like" operator and cannot come up with the right syntax. The basic code is shown below and before it is suggested, I have also tried this with the SWITCH operator with similar errors. The expression editor moves the error around based on the parenthesis. This particular expression is in the "fill" property of a matrix in an SSRS report. I really want to set the color on a match and leave it unchanged for no match. For the code below the expression editor shows an error on the first comma after the text "Preferred".
=iif((Fields!PHASE_TYPE.Value like "*Preferred*","ForestGreen","Blue") or
(Fields!PHASE_TYPE.Value like "*Maintain*","DarkSeaGreen","Red"))
Your syntax is not quite right for a IIF function. It takes 3 parameters, and you are only really giving it one.
You are going to need to change your expression to some like the one below.
=Switch(Fields!PHASE_TYPE.Value like "*Preferred*","ForestGreen",
Fields!PHASE_TYPE.Value like "*Maintain*","DarkSeaGreen",
True, "White") ' This last part will catch anything that does not match the above

SSRS Formatting Number

I'm having troubles using an expression in one on my textboxes. I need all null values to display as 0, which I have done correctly. However, if the number is a decimal, say 126.5000, I need it to just display as 126. I was thinking about using the FIX function like so...
=IIF(IsNothing(Sum(Fields!PROP__QTY.Value)), "0", Fix(Sum(Fields!PROP__QTY.Value)))
however when I do that I get #ERROR where the 0's should be displayed. The fix function works though. If I take the Fix out, then the 0's display proper as well. Is my syntax not correct? I'm fairly new with SSRS so any guidance would be awesome. Thanks!
You appear to be mixing types try , 0 , rather than , "0" , as this changes it from a number to text
I personally would use CInt to convert the result rather than Fix
=IIF(IsNothing(Sum(Fields!PROP__QTY.Value)), "0", CInt(Sum(Fields!PROP__QTY.Value)))

how to solve SSRS Formatting issue?

Currently the data in field is coming like this 9646.88 and my requirement is
Remove decimal places and add comma for thousands e.g. 9,646
=IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value)
Please help, I am a newbie in SSRS.
Go to Properties pane when you select the textbox.
Then put this on Format property
#,0;(#,0)
Using Common Functions such as Text and Conversion functions shown in Expression window will give you the desired result.
For e.g,
Format(Int(9646.88), "#,###") // try "#,##0" which returns 0 if less than 1
where Int(9646.88) returns the integer portion of the number 9646 and Format(9646,"#,###") returns a string formatted according to instructions contained in a format String expression "#,###" which is a thousand seperator. Thus, it will give you "9,646".
So, in your case, try this,
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT", "", Format(Int(Fields!BASE_RENT_PM.Value),"#,###"))
Note:
Format(9646.88, "#,###") will return a rounded result 9,647 and
Format("VACANT", "#,###") returns just "#,###",
none of which may not be your desired result.
Have your Tried this?
=FORMAT(IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value),"#,###")
Should solve your issue.
Kind Regards
To add comma for thousands, you need to change your expression.
If you need output as 9,646 then try below.
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(Convert.ToInt32(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
OR
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(CInt(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
Updated Answer:
As you want to handle null values as well I would suggest below way to achieve your goal.
Set Textbox visibility with below expression.
=IIF(ISNOTHING(Fields!BA‌​‌​‌​SE_RENT_PM.Value),True,False)
So if null value is there then it will show blank in the ssrs report.

SSRS IIF Multiple expression not working

Please see pic
For some reason my expression is not working and I cannot figure out why...
What I'm trying to do is check the UseByDate if it's blank set time to blank AND if pickeddatetime is blank (time field) also set to blank if not blank use pickeddatetime. However my expression doesn't seem to be working correctly for some reason?
=IIF(Fields!UseByDate.Value is nothing, nothing, IIF(Fields!PickedDateTime is nothing, nothing, FORMAT(System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!PickedDateTime.Value), "HH:mm")))
I've checked the pickeddatetime value and it is definitely null for this row.
Replace Fields!PickedDateTime with Fields!PickedDateTime.Value
I think the way the expression is written isn't checking for nothing correctly. Try:
=IIF(IsNothing(Fields!UseByDate.Value)=True, nothing, IIF(IsNothing(Fields!PickedDateTime)=True, nothing, FORMAT(System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!PickedDateTime.Value), "HH:mm")))