I want to use columns in a function and the columns may differ from time to time. So I want to pass the columns into the function when calling the function, what datatype can be used in the function.
The following is the code that i want to put into the function and compute_page is the column name:
if dw_report.Object.compute_page[ll_first_row] <> dw_report.Object.compute_page[ll_last_row] then
Also, I want to do the same thing but this time is set the column value. I tried to use SetItem(), SetText(), SetValue(), but none of the function can achieve the expected result except using dwcontrol.Object.columnname[i] to set the value.
Thanks
Instead of using the .object notation to access the column, use the GetItemxxx(), eg:
if dw_report.getitemnumber(ll_first_row, "compute_page") <> dw_report.getitemnumber(ll_last_row, "compute_page") then
Just replace the "compute_page" litteral in the example by a string argument of your function.
Beware that the GetItemxx() call must match the actual column data type, so you need to check for the result of dw_report.describe(ls_your_column_name+".coltype") to call one of GetItemNumber(), GetItemString(), GetItemDecimal(), GetItemDate(), GetItemDatetime() or your application will crash.
Related
I am passing a unique ID as parameter in SSRS report. In the source table, unique id does not contain dashed. However, the user may insert Unique ID including dashes "-" and in some cases without dashes. Is there a way that we could remove dashes from the parameter.
For example, unique id 3120-20268-8 is stored in table as 3120202688. How I could retrieve if user pass multiple values with or without dashes in the SSRS Report.
When is used below query, it gives record against single value only. However, gives error when more than one values are provided.
select * from Table
where Unique_ID in (REPLACE(#Unique_ID,'-',''))
For more than 1 values, it gives errors mentioned below:
The replace function requires 3 argument(s).
Query execution failed for dataset 'ATL_List'.
Thanks
One of the simplest mechanisms for this is to create an expression based parameter to hold the sanitised input. This parameter would be hidden so the user is not aware of it, but the rest of the usage of the parameter is the same.
NOTE: You could do something similar with a query based default value, but this case is easier to do via a simple expression
Single Value Parameter
Create a new parameter:
set it to hidden
Set the default value expression:
=Str(Parameters!inputID.Value).Replace("-","")
Multi-Value Parameter
This is only slightly trickier, in the expression we can join the selected values together into a CSV string, then process that value and then split it back:
Set the parameter to multi-value, but still hidden:
Set the default value expression:
=Join(Parameters!inputID.Value,",").Replace("-","").Split(",")
Without going to detailed, if we made the sanitised parameter temporarily visible, just to demonstrate the conversion, it should look like this:
The parameter MUST be hidden!
NOTE: DO NOT make your sanitised parameter visible as in the above screenshot in your deployed report! Doing so will mean that it will not pickup changes made to the input value after it has rendered the first time.
remember that we have exploited the default value, we haven't arbitrarily defined en expression to always execute.
The output when the parameter is hidden is calculated when the report is rendered, it's just harder to visualise the behavior in this static post:
In your DataSet query you would just use the sanitised parameter:
SELECT * FROM Table WHERE Unique_ID IN (#sanitisedMultiValue)
You should be able to use the replace function in your report to format the parameter value after it has been entered, something like the below
replace(Fields!Paramater.Value,"-","")=FieldinYourTable
I'm trying to pass a report variable to an expression used to populate textbox but it's giving me syntax error. Here's the expression.
=Fields!Variables!col1.Value.Value
The variable (Variables!col1.Value) should return a fieldname that I want to use to populate a textbox inside a table.
Edit:
Basically I have a multi-value parameter that passes on to a stored procedure that pulls the data based on the parameter value. The first 4-5 columns returned are static while the rest are dynamic and can have unknown number of columns but I do know the max number of columns.
What I'm trying to do is to create a fixed number of columns and then show/hide them based on the parameter. I get the column title via an expression (=Parameters!Course_IDs.Label(0)) and then I want to use this value to create a textbox that will populate the column based on this value Course_IDs.Label(0).
Since it is a multi-valued parameter, you will likely need to join the results:
=JOIN(Parameters!ParameterName.Value, ", ")
If it is a variable from the dataset you will likely need to use LOOKUPSET() to get the values.
Also note that parameter values might be ugly to look at. In that case use the name instead - Parameters!ParameterName.Label
I'm trying to create an expression with a missing column. as in the column is not returned from the query but does exist in the list of fields.
The problem I'm having is that every time I do an expression and one of the parameters is from a field that doesn't have a return from query the query fails silently. the following example is looking at a field "test" that, as I said, exists in the list of fields but is not returned from the query, how can I have this is statement send "alert"??
=IIF(Fields!test.IsMissing,"alert",Fields!test.Value)
The reason that I don't return the field is that the columns are dependent on the parameters I enter in the procedure (so they could be used or not depending on what the user is asking)
Thank you
From reading your question I think, you have dynamic columns which will be returns conditionally
So what you should do is,
1) Create the parameter in the parameter list and set it as the internal and assign the field value to that parameter, suppose the parameter is dyanmicfiledvalue
2) Change your expression as,
=IIF(IsNothing(Parameters!dyanmicfiledvalue.value),"alert", Parameters!dyanmicfiledvalue.value )
that should do it. Let me know in case of issues.
Or if you want to check null or empty value for that column just change as
=IIF(IsNothing(Fields!test.value),"alert",Fields!test.value)
I have a dataset FiscalYearMonth which contains
Fiscalmonthyear
Fiscalmonthkey
I have also Parameters!FiscalYearMonth.Value
How can I get Fiscalmonthkey for FiscalYearMonth parameter ? I tried the following expression but didn't work
=lookup(Fields!FiscalMonthYear.Value,Parameters!FiscalYearMonth.Value, Fields!FiscalMonthKey.Value, "FiscalYearMonth")
I think you have your function parameters in the wrong order, try this:
=lookup(Parameters!FiscalYearMonth.Value, Fields!FiscalMonthYear.Value, Fields!FiscalMonthKey.Value, "FiscalYearMonth")
This bascially says "in the dataset 'FiscalYearMonth', compare the value of Parameters!FiscalYearMonth.Value to the field Fields!FiscalMonthYear.Value for each row in the dataset and return the value of Fields!FiscalMonthKey.Value where there is a match".
Note that the Lookup() function only returns a single value and will stop at the first match found.
Question: I want to use a VBA function in Access that is declared as type Long. I want to return an integer between 0 and 35 some of the time, but I also want to be able to return a blank or null or something like that most of the time. Is there a way to do this? What I have tried (variable = "" or Set variable = Nothing) just calls an error. This will be used in a query and will give the value for one column. I want that column to be type Long. If such a thing is not possible, I guess that is all I need to know, as I already have a different but less desirable solution. Thanks for any help.
Update: Of course, right after asking the question, I figured out a good solution. If I just do Range("whatever").Value = Range("whatever").Value in Excel, then it changes a left aligned 20 to a right aligned 20, at which time it is recognized by the pivot table as a number (though when I just convert the cell type to a number in Excel, it is not recognized as a number in the pivot table). So, I am deleting the background because it is not necessary. I am still interested to know if you can return some sort of blank or null for a function declared as long. Thanks
Null can only be returned from a Variant function.
Nothing can only be returned from an Object function.
All others, you are restricted to returning a variable of the type defined as the return value of your function.
If you do not set a value, then it returns the default value
A numeric variable is initialized to zero
A variable length string is initialized to a zero-length string ("")
A fixed length string is filled with the ASCII code 0.
A date/time variable is initialized to zero
Since an unitialized long has a value of 0, the answer is "no." A function declared as long cannot return null or blank. If zero wasn't a valid return value for your function, you could use it a "null" equivalent, but you already knew that :)