I am attempting to control the visibility of an error message with the following code:
=IIf((Lookup(Parameters!FA.Value, Fields!fa_num.Value,Fields!LastName.Value,"Advisor_Numbers")=""),False, True)
What this theoretically should do is look at the FA # inputted by the user, then look within the "Advisor_Numbers" dataset for a match in fa_num...and once found to check if the last name of the advisor is empty.
If this is true: return false. Otherwise, return true.
This code always returns false despite the sample FA numbers I use existing in the Advisor_Numbers table. Is my syntax for writing a parameter within a lookup incorrect?
Ideally I'd just like to lookup if the parameter exists within the table without involving the last name.
I found the solution to my own problem.
While everything looked fine on the surface, there was probably some empty space somewhere in my data. Therefore, make sure to use Trim.
=IIf((Lookup(Trim(Parameters!FA.Value),Trim( Fields!fa_num.Value),Trim(Fields!LastName.Value),"Advisor_Numbers")=""),False, True)
The code above worked smoothly and solved all my issues
Related
I need some help with an Access expression. I keep getting a syntax error.
I'm trying to get a calculated field from the combination of another calculated field.
Note that the LaserCuttingRate field is also a Lookup field. So it's not a simple entry field. It becomes a selector of the 3 choices.
IIf([LaserCuttingRate]="200",([CuttingTime]*200/60),IIf([LaserCuttingRate]="400",([CuttingTime]*400/60),IIf([LaserCuttingRate]="100",([CuttingTime]*100/60)))
All help appreciated.
Cam
I think you're missing a final close bracket.
There are 6 open brackets ( but only 5 closing brackets )
UPDATE - second issue
Two extra issues
The checks on number either don't need, or shouldn't have double-quotation masks
The final IIF also needs a false clause at the end (in the example below, 0).
Try this - I have put it into an Access database scratch table and it worked. (If relevant, note that I had LaserCuttingRate and CuttingTime set as doubles, as well as the Result Type for the calculated column).
IIf([LaserCuttingRate]=200,([CuttingTime]*200/60),IIf([LaserCuttingRate]=400,([CuttingTime]*400/60),IIf([LaserCuttingRate]=100,([CuttingTime]*100/60),0)))
I am trying to determine how a file path value on a shared server (output of the DLookUp function in Access) is getting populated.
I have a field on a Form that is getting it's Control Source from the following formula:
=DLookUp("[DefaultOuptputDir]","Defaults")
When I search in the VB Editor, I can not find any references at all to "DefaultOuptputDir" (the spelling is correct as it was originally created). I can also not find any reference to the actual Path being populated below, so I don't believe it is hardcoded in a form.
Ultimately I want to change this path to one I can access, but I need to understand how this is getting populated now. Looking for input on what I should be checking, thanks!
DLookUp is a function which searches table for some criteria and returns some field
DLookUp(field, table, criteria)
In your case it shows value of DefaultOutputDir in table Defaults and i suspect this table have only one row so the third argumet is ommited.
That will be the value stored in the first record of a field called DefaultOuptputDir In a table called Defaults.
So, I have a problem in Report Builder that is just driving me absolutely crazy.
I have two dataset; one called DS_Grades and the other DS_Pupils. I want to do a simple LookUp based on PupilID, a field that is in both datasets, and return a grade from DS_Grades into a Matrix based on DS_Pupils.
The formula I am using is:
=LookUp(Fields!PupilID.Value, Fields!PupilID.Value, Fields!Grade.Value, "DS_Grades")
I have confirmed that:
1) DS_Grades has the right PupilIds
2) There are actually values in the Grades field
3) Both PupilID fields (I.E. in both datasets) are definitely Integers and not text.
Moreover, if I add a calculated field to DS_Grades called "test" and populated with the value 208301, which is a valid PupilID, then I can enter the below formula and it works fine:
=LookUp(208301, Fields!test.Value, Fields!Grade.Value, "DS_Grades")
So, the LookUp itself must be matching properly, which means that the PupilID fields must be causing the problem, but I have quintuple freaking checked them and they definitely have the right values, in the right format. I am at a total loss as to why SSRS thinks that they don't match.
Help please!
Got it! Some filtering was at Dataset Level (instead of query where I normally do it) that was throwing the whole thing out of joint. Removed that, and it's fine.
I am trying to add an optional filter on a text field in a report. I have tried setting it up in the dataset but it treats it as a required filter so if it is not populated, no results are returned. It needs to use the Like operator. Any advice?
As I was typing out a work-around to this problem, I realized an incredibly easy solution (now that I understand better how it works).
Here's what I did:
Since Hong pointed out that all filter conditions must be met, I reversed my thinking. I moved my existing "IN" filters to the query and fed the parameter directly to the query. Then I created by "LIKE" text filter on the report which a default value of "*" so it would immediately return everything.
Here's what I could've done:
Just the last part. Added the "LIKE" filter with a default value of "*" so it immediately returned everything.
I also agree that most of the time it's best to send the params back to SQL. Since that's not what the OP is asking, here is the best option I have found for doing this. And it is actually quite simple.
Add your parameter with the appropriate data type. Let's use the
example of a "City" in this case (a text/string field).
Check "Allow Nulls" on the parameter.
Add a filter to either a tablix, table or dataset.
In the expression, select the field you want to filter on. Select the appropriate operator, in my example of a data set with Cities, in the Value put in this:
=IIF((Parameters!City.Value Is Nothing), Fields!City.Value, Parameters!City.Value)
I don't think you can make an optional filter in DataSet Properties/Filters, adding filters there means returning results that match ALL filter contiditions, so it is "AND" logical relation among all filters, not "OR".
My sugguestion is to use filter in query designer of the dataset, where you can define "OR" relations to filter out data. For instance: Your_Text_Field="SomeValue" OR Your_Text_Field is Empty.
Although I agree that most of the time it is best to send the parameters back to the stored procedure or data layer to reduce the amount of data returned, I have a case where it is just as easy to do the parameter handling in the RDL file via a filter. Due to this unique situation I found this solution which gives you a way to create an Optional filter in the RDL file.
http://www.andrewshough.com/development/sqlserver/ssrs/optional-filter-in-ssrs/
It is a great blog post with easy step by step instructions on how to create an optional filter.
Please Note: This is NOT my blog but I though this solution was great for what I needed and I hope it helps someone else when they google for "optional filter in SSRS" like I did.
I found a post which solved my problem setting the filter for a report-consumer to a) all multivalue fields being selected so the user b) could specify his/her selection if necessary.
Kasim 8 Dec 2010 8:55 AM #
In reports when we want to default the multivalue parameter to 'Select All' following are the steps.
Open the Report parameter window from the Report menu.
Select the Report parameter from the left handside of the window.
Select 'Multi-value' checkbox and appropriate 'Available values'.
Under default values select 'From Query' radio button'.
Select the appropriate 'Dataset'.
Select appropriate 'Value Field'.
Save the Report and select Preview Tab. You will find all the items selected in the multivalue >parameter list and the result displayed for all the selected items.
found on: http://blogs.msdn.com/b/bimusings/archive/2007/05/07/how-do-you-set-select-all-as-the-default-for-multi-value-parameters-in-reporting-services.aspx
(The Post came up in the comments quite in the middle.)
You can accomplish this by using an expression on the dataset filter.
Check this
Below is the snippet of an mdx query used in a report.
with member [Measures].[Leased Coin In]
([Machine Dimension].[Leased Flag].&1 , [Measures].[Coin In])
Now, my question is:
In the cube under Machine Dimension, there is no attribute hierarchy name called Leased Flag.
I looked at in the xmla script, there is no such name. But, the mdx query pulls result out.
If it is hidden, why does not it appear in the xmla script as hidden/invisible or whatever it is?
If I m missing something, then how do I track it back to find out how it is related with the machine dimension.
Appreciate your help.
Have you tried running the query in SSMS? The &1 is not a valid identifier. Identifiers must start with an alpha character or be delimited with square brackets.
It is possible to write a calculated measure that references a non-existant hierarchy or member, but it would just return null. However a reference to &1 should not even get past the parsing stage of the query evaluation without throwing an error.
Old message but for those googling:
When you see something like [Dimension].[Hierarchy].&[1] (I'm assuming the [ ] around the 1 were just left out when entering the message) that is referring to the key of the member in the attribute as opposed to the caption of the member.
The typical place you see this is when using Dimension Security and looking on the Advanced tab or when choosing a Default Member. This lets you rename a member without breaking your cube logic.