I have a row group of STATUS fields. There is a group that returns null that I would like to change to chat. I have tried:
=Iif(IsNothing(Fields!STATUS.Value), "Chat", Fields!STATUS.Value)
but the group still returns blank. Would anyone have any ideas on how to help me resolve this?
Your code is right. Are you sure it's returning nothing, and not something like a space or carriage return?
Related
When I run my expression, I get 6 inside of 5 as the expression is counting space. Can anyone please help to amend my expression
=CountDistinct(IIF(Fields!EnrolmentAtRiskStatus.Value ="No Risk", Fields!RefNo.Value,""))
CountDistinct counts non null values. An empty string is not null.
try the following
=CountDistinct(IIF(Fields!EnrolmentAtRiskStatus.Value ="No Risk", Fields!RefNo.Value,nothing))
When I´m running ssrs I have an issue with my field month because value is:
[Dim_Tiempo_].[Mes].&[6]
So I try to substring to get only value 6:
=CINT(Left(Right(Parameters!DimTiempoMes.Value(0),3),2))
But I just get #Error without specifications why. Can someone help me there?
When you go right and get the last 3 characters, you get [6], then you go left 2, you get [6.. converting this to an int is obviously going to return and error. if you didn't put the CINT.. you would have seen what was happening.. what you need is the following
=cint(replace(left(Split(Parameters!DimTiempoMes.Value(0),"[").GetValue(3),2),"]",""))
I am getting this error every time this report is rendered. I looked at the group expression for this group and it looks like this:
=Trim(Left(Fields!ILS_LS_USER_10.Value,InStr(Fields!ILS_LS_USER_10.Value,"->")-2))
The field ILS_LS_USER_10.Value is: BNST -> USWEOLN
I can't see the error. Can anyone help me diagnose this error, please?
It works if you put the string literal in place of Fields!ILS_LS_USER_10.Value.
The issue is that it isn't getting the value of the field as a string by default. Use the ToString() method after .Value and it should work, or at least it did on my machine.
=Trim(Left(Fields!ILS_LS_USER_10.Value.ToString(),InStr(Fields!ILS_LS_USER_10.Value.ToString(),"->")-2))
I found that the Group expressions, for some reason, do not seem to like the subtraction in the InStr. Leave out the subtraction and it works.
In fact, take the same formula, and place it into a placeholder in the Group and it seems to work just fine. Replaced with Split in the Group expression and it works.
This was on SQL Server 2016, using Report Builder.
I always thought that when a stored procedure brought back a null datetime that an SSRS report would show mindate in that cell. The thing is, in my experience this is not always true. I can't figure out why. Sometimes a report will show blank and sometimes mindate for a null datetime. Why is that?
Is there rules or documentation (that makes sense) that explains how this works? It's hard to be consistent when the tools you are using are not consistent. I can make two reports that are set up exactly the same way. One will show mindate and one will show blank for null datetimes. I don't get it.
EDIT:
First of all, yes the mindate thing has happened to many.
https://www.google.com/search?num=50&q=ssrs+null+date+show+blank&oq=ssrs+null+date+show+blank&gs_l=serp.3...8759.9774.0.9941.10.10.0.0.0.0.152.888.8j2.10.0....0...1c.1.25.serp..8.2.166.kl2WBVx4Ijw
Almost every result has someone talking about the mindate when they want a blank. Many of the results are from Stack Overflow so before you start telling me it never happens, realize you are flat wrong. You may have never seen it. I have never seen a severed finger in my food in all my years of eating and thousands of meals. Doesn't mean it hasn't happened to someone.....
Example of one that is showing min date:
In the report the expression for the text box is:
=Fields!SecondaryInjuryRecordDate.Value
The number formatting was set to Date->01/31/2000 in the placeholder properties window.
Pretty straightforward, nothing weird going on there. RIGHT?
In the proc, the code for that column is:
CASE WHEN ISNULL(l.SecondaryInjury, 0) = 0 THEN '' ELSE l.SecondaryInjuryDXDate END AS SecondaryInjuryRecordDate
That resulted in mindate being shown whenever SecondaryInjuryDXDate was null. I had to switch to this:
CASE WHEN ISNULL(l.SecondaryInjury, 0) = 0 THEN '' ELSE ISNULL(l.SecondaryInjuryDXDate, '') END AS SecondaryInjuryRecordDate
...to get blanks when the date was null.
SecondaryInjuryDXDate is a DATETIME and
SecondaryInjury is a bit.
Within SSRS, by default a NULL DateTime value will be represented as an empty string instead.
If data formatting is applied to the value, a MIN DateTime value will be used in place of the null value e.g.: converting the DateTime to a ShortDate as described:
The number formatting was set to Date->01/31/2000 in the placeholder properties window. Pretty straightforward, nothing weird going on there. RIGHT?
To avoid this, the column value must be wrapped in an expression to conditionally apply the required formatting:
=IIf(IsNothing(Fields!DateTimeField.Value), "", FormatDateTime(Fields!DateTimeField.Value, DateFormat.ShortDate))
Use something like this in textbox expression:
=IIf(IsNothing(Fields!DateTime.Value), "", Fields!DateTime.Value)
It looks like there is no documentation to be found about this. The next best thing is to have this Q&A document things based on our collective experience.
Supposing the question: "What does SSRS do when displaying a DATETIME with a NULL value?"...
...the answer is it will display an empty string instead. There is no reproducible scenario where a NULL value would be displayed as anything else, unless you do some work to that end yourself, for example:
If the query COALESCEs the NULL to something else, e.g. the string "NULL" or a MIN DATETIME;
If you have an expression for the textbox value, e.g. IIF(Fields!MyDateTime.Value Is Nothing, "01-01-1900", Fields!MyDateTime.Value)
Every field returned in a SQL query gets a datatype assigned. Generally, you want to keep dates returned as dates from SQL, not as strings. (Don't format the date to a string in SQL. Do that as close to the presentation layer as possible.)
So instead of this in your query:
CASE WHEN ISNULL(l.SecondaryInjury, 0) = 0 THEN '' ELSE l.SecondaryInjuryDXDate END AS SecondaryInjuryRecordDate
I would try to use:
CASE WHEN ISNULL(l.SecondaryInjury, 0) = 0 THEN CAST( NULL AS DateTime ) ELSE l.SecondaryInjuryDXDate END AS SecondaryInjuryRecordDate
See SQL cast datetime for an explanation of why you are getting 0 cast to a date.
I did find when I format an entire column such as FormatDateTime(field, DateFormat.ShortDate) - SSRS will format that blank field to 01/01/0001. Just an FYI.
My situation/problem:
TableA
id, postalcode, region
Criteria for the field i want to add value in (postalcode):
=IIf([tableA.Region]="Chicago","60064",[postalcode])
What i need to accomplish is an iif-query where:
In the field postalcode I check in the criteria if the field region equals Chicago. If so fill up the field with postalcode 60064 if not DO NOTHING
For the do nothing part I'm using the fields name, this is wrong?
am i using the criteria in the right field (the field i want to add?)
I'm using a selection query?
As you can see i'm a noob in access queries...
Can somebody give me the right iff statement?
Thx in advance,
D
I'll suggest you bracket table.Region differently, or eliminate the brackets there entirely.
=IIf([tableA].[Region]="Chicago","60064",[postalcode])
=IIf(tableA.Region="Chicago","60064",[postalcode])
If that doesn't fix the problem you're trying to solve, tell us more about the problem. If you're getting an error message, tell us what it says.
Taking a wild guess, that code as a field expression in a query will not give you an editable column in the query result set. If you want to pre-load a column value based on your criteria, but then allow the user to change the value, use a form. In the form's On Current event, load the value as you wish.
This is a dead old post but I think this was what you wanted:
=Like IIf([tableA.Region]="Chicago","60064",'*')
As far as I can understand,
if not DO NOTHING
You need to return nothing if the condition is false.
What you need is the WHERE clause instead of IIF
If I'm understanding your question correctly, you want a NULL value in Postal Code if it's not Chicago?
=IIf([tableA].[Region]="Chicago","60064","")
Please add another IIF query as OR
IIf([Forms]![Run_Macro
Form]![ReturnType_DrpDwn]="Monthly",[Forms]![Run_Macro
Form]![Cmb_Per_Ending],#1/1/2010#)
IIf([Forms]![Run_Macro Form]![ReturnType_DrpDwn]="Quarterly",#1/1/2010#,#1/1/2025#)