Parameter field with multiple values not working - crystal-reports

Setup a Parameter field with multiple values to be used in a SQL query command and it does not work when more than one value is selected, but works fine with one value selected. And yes, the "Allow multiple values" flag is set to True under Options.
I am trying to go from this:
EMPBNFIT.BENEFITPLAN in ('CONSUMER CHOICE','HMO', 'HS HMO','HS NETWORK CHOICE','HS PPO BASIC NH RPN','HS PPO PLUS NH RPN','MFS CONSUMER CHOICE','NETWORK CHOICE','PPO BASIC NH RPN','PPO PLUS NH RPN','WAIVE MEDICAL')
to this:
WHERE EMPBNFIT.BENEFITPLAN in ('{?MyPlans}')

What a coincidence; had the same problem this morning. I was able to make a workaround in Crystal by converting the array of multiple parameters into a single string, then replacing the IN section with an INSTR comparison.
Make a formula called ParamFix with this logic:
REPLACE(JOIN({?MyPlans}, ","), "&", "; ")
In my case, the different values were separated by an &, but you can replace that based on what comes back from the tables. Then replace the IN comparison with:
INSTR({#ParamFix}, EMPBNFIT.BENEFITPLAN) > 0

Related

Azure Data Factory - Data Wrangling with Data Flow - Array bug

Azure Data Factory - Data Wrangling with Data Flow - Array bug.
I have a tricky firewall log file to wrangle using Azure data factory. The file consists of 4 tab-separated columns. Date and Time, Source, IP and Data.
The Data column consists of key-value pairs separated with equal signs and text delimited by double-quotes. The challenge is that the data column is inconsistent and contains any number of key-value pair combinations.
Three lines from the source file.
2022-02-13 00:59:59 Local7.Notice 192.168.40.1 date=2022-02-13 time=00:59:59 devname="NoHouse" devid="FG100ETK18006624" eventtime=1644706798637882880 tz="+0200" logid="0000000013" type="traffic" subtype="forward" level="notice" vd="root" srcip=192.168.41.200 srcport=58492 srcintf="port1" srcintfrole="undefined" dstip=216.239.36.55 dstport=443 dstintf="wan1" dstintfrole="undefined" srccountry="Reserved" dstcountry="United States" sessionid=137088638 proto=6 action="client-rst" policyid=5 policytype="policy" poluuid="c2a960c4-ac1b-51e6-8011-6f00cb1fddf2" policyname="All LAN over WAN1" service="HTTPS" trandisp="snat" transip=196.213.203.122 transport=58492 appcat="unknown" applist="block-p2p" duration=6 sentbyte=3222 rcvdbyte=1635 sentpkt=14 rcvdpkt=8 srchwvendor="Microsoft" devtype="Computer" osname="Debian" mastersrcmac="00:15:5d:29:b4:06" srcmac="00:15:5d:29:b4:06" srcserver=0
2022-02-13 00:59:59 Local7.Notice 192.168.40.1 date=2022-02-13 time=00:59:59 devname="NoHouse" devid="FG100ETK18006624" eventtime=1644706798657887422 tz="+0200" logid="0000000013" type="traffic" subtype="forward" level="notice" vd="root" srcip=192.168.41.200 srcport=58496 srcintf="port1" srcintfrole="undefined" dstip=216.239.36.55 dstport=443 dstintf="wan1" dstintfrole="undefined" srccountry="Reserved" dstcountry="United States" sessionid=137088640 proto=6 action="client-rst" policyid=5 policytype="policy" poluuid="c2a960c4-ac1b-51e6-8011-6f00cb1fddf2" policyname="All LAN over WAN1" service="HTTPS" trandisp="snat" transip=196.213.203.122 transport=58496 appcat="unknown" applist="block-p2p" duration=6 sentbyte=3410 rcvdbyte=1791 sentpkt=19 rcvdpkt=11 srchwvendor="Microsoft" devtype="Computer" osname="Debian" mastersrcmac="00:15:5d:29:b4:06" srcmac="00:15:5d:29:b4:06" srcserver=0
2022-02-13 00:59:59 Local7.Notice 192.168.40.1 date=2022-02-13 time=00:59:59 devname="NoHouse" devid="FG100ETK18006624" eventtime=1644706798670487613 tz="+0200" logid="0001000014" type="traffic" subtype="local" level="notice" vd="root" srcip=192.168.41.180 srcname="GKHYPERV01" srcport=138 srcintf="port1" srcintfrole="undefined" dstip=192.168.41.255 dstport=138 dstintf="root" dstintfrole="undefined" srccountry="Reserved" dstcountry="Reserved" sessionid=137088708 proto=17 action="deny" policyid=0 policytype="local-in-policy" service="udp/138" trandisp="noop" app="netbios forward" duration=0 sentbyte=0 rcvdbyte=0 sentpkt=0 rcvdpkt=0 appcat="unscanned" srchwvendor="Intel" osname="Windows" srcswversion="10 / 2016" mastersrcmac="a0:36:9f:9b:de:b6" srcmac="a0:36:9f:9b:de:b6" srcserver=0
My strategy for wrangling this data set is as follows.
Source the data file from azure data Lake Using a tab-delimited CSV
data set. This successfully delivers the source data in four columns
to my data flow.
Add a surrogate key transformation to add an incrementing key value to each row of data.
Add a derived column,
with the following function.
regexSplit(Column_4,'\s(?=(?:[^"](["])[^"]\1)[^"]$)')
This splits the data by spaces ignoring the spaces between semicolons.
Then the unfold creates a new record for each item in the array while preserving the
other column values.
unfold(SplitBySpace)
Then split the key-value pairs into their represented value and key by the Delimiter equals.
The final step would then be to unpivot the data back into columns with the respected values grouped by the surrogate key added in step 2.
This all sounds good but unfortunately step 5 fails with the following error. “Indexing is only allowed on the array and map types”.
The output after step 4.
The unfold function returns an array according to the inspect tab, see below. I would expect a string here!!
Now in step 5, I split by “=” with the expression split(unfoldSplitBySpace, '=') but this errors in the expression builder with the message “Split expect string type of argument”
Changing the expression to split(unfoldSplitBySpace1, '=') remove the error from the expression Builder.
BUT THEN the spark execution engines errors with “Indexing is only allowed on the array and map types”
The problem.
According to the Azure Data Factory UI, the output of the Unfold() function is an array type but when accessing the array elements or any other function the spark engine does not recognise the object as in array type.
Is this a bug in the execution or do I have a problem in my understanding of how the data factory and a spark engine understand arrays?
Split() function splits the string to multiple values based on delimiter and returns array type.
If you are splitting value of array of particular index, mention the index with in braces [].
Example:
Here I have an array value ["employee=Robert", "D"], and using split(), I am splitting the value of index 1 based on =.
split(value[1], '=')
Microsoft-help provided an answer.
First, it looks like a bug.
Second, there is a workaround. Cast the array output to string with toString(unfold(SplitBySpace))
https://learn.microsoft.com/en-us/answers/questions/860243/azure-data-factory-data-wrangling-with-data-flow-a.html#answer-865321

How do I prevent users to use thousands separator in FileMaker Pro?

In FileMaker Pro, when using number field, the user can choose to use a thousand separator or not. For example, if I have a database with a field for the price of an item, the user can either enter 1,000 or 1000.
I am using my database to generate an XML file that needs to be uploaded. The thing is, that my XML scheme dictates that only a value of 1000 is allowed and not 1,000. Therefore, I want to either automatically remove the comma, or (my preference in this case) alert the user when trying to enter a value with a thousand separator.
What I tried is the following.
For the field, I am setting Validation options. For example:
Require Strict data type: Numeric Only
Validated by calculation: Position ( Self ; ","; 1 ; 1 ) = 0
Validated by calculation: Self = Substitue ( Self, ",", "")
Auto-enter calculation: Filter( Self ; "0123456789." )
Unfortunately, none of these work. As the field is defined as a number (and I want to keep it like this, as I am also performing calculations based on this number), the Position function and the Substitute function apparently ignore the thousand separator!
EDIT:
Note that I am generating my XML by concatenating a string, for example:
"<Products><Product><Name>" & Name & "</Name><Price>" & Price & "</Price></Product></Product>"
The reason is that what I am exporting is dependent on the values in my database. Therefore, I am not using the [File][Export records...] function.
Auto-enter calculation will work, but you need to uncheck the box "Do not replace existing value of field" (which is checked by default).
I'd suggest using the calculation GetAsNumber(self) as the auto-enter calc. If it should only contain integers, wrap that in a call to Int()
I am using my database to generate an XML file that needs to be uploaded. The thing is, that my XML scheme dictates that only a value of 1000 is allowed and not 1,000.
If this is only a problem when you export, why not handle it when exporting?
If you are exporting as XML using XSLT, you can add an instruction to
your stylesheet to remove the comma from all number fields;
Alternatively, you can export from a layout where the field is
formatted to display without the comma and select the Apply current's layout data formatting to exported data option when
exporting.
Added:
Perhaps I should have clarified. I am not using the export function to generate the XML as there is some logic involved in how the XML should be formatted (dependent on the data that I want to export). What I do instead is that I make a string where I combine XML-tags and actual values from the database.
IMHO, you're making a mistake by not taking advantage of the built-in XML/XSLT export option. Any imaginable logic can be implemented this way, without burdening your solution with the fragile task of creating a valid XML.
In any case, if you're using the field in a calculation, you can replace all references to it with:
GetAsNumber (YourField )
to get an unformatted, numeric-only, value.
Your question puzzles me. As far as I know, FileMaker does not store the thousands separator, but rather offers it only as a display option.
That's also why those functions can't find it.
Are you sure you are exporting the raw data and not a "formatted as layout" variant?

BIRT report parameter multiple selection value "All"

I have a problem with creating default value of 'All values' for a cascading parameter group last parameter. Actually I don't neccesary need that value to be default, but that would be preferable.
I have tried where I create additional data set with the needed value and additional data set with value All which uses different scripted data source, and another data set with computed column with full outer join, that column uses this code
if(row["userName"]==null ){
row["All"];
}else{
row["userName"];
}
and in the last cascaded parameter JDSuser which I need that All value I have added default value (All users).
In the data set with one value All in open I have script
ii=0;
in fetch
if( ii > 0 ){
return false;
}else{
row["All"] = "(All Users)";
ii++
return true;
}
and in the query data set, in beforeOpen script in if statement I have
if( params["JDSuser"].value!=null && params["JDSuser"].value[0] != "(All Users)" ){
This is used if I haven't selected All users value, and this works, though if I select All Users, it retrieves me no data.
I'm creating from this source example actuate link for example rptdesign download
If someone could give me some help, I would be very grateful.
The way you generate "(All values)" item in your selection list seems to me over complicated but if i understood correctly your case this part is working fine, the problem is not in the definition of the cascading parameter but the way it is used in the main dataset of the report.
Furthermore we have to assume we speak about the same query & beforeOpen script involved in this topic. No data are returned because if we don't do anything special when this item "All values" has been selected, then those filters are still active:
and role.name in ( 'sample grupa' )
and userbase.userName in ( 'sample' )
There are a couple of options to handle this. An elegant one is to declare a dataset parameter linked to your report parameter "JDSuser", and use a clause "OR" such:
and role.name in ( 'sample grupa' )
and (?='(All users)' OR userbase.userName in ( 'sample' ))
Notice this question mark, which represents a dataset parameter in your query. It is not intrusive: the beforeOpen script doesn't have to be changed. You probably need to do something similar with the other filter role.name, but you don't provide any information related to this. One more thing, in order to avoid bad surpises may be you should choose as value something more simple without brackets such "_allitems", and set "(All items)" as label.
Please refer to this topic for more informations about handling optional parameters. See a live example of optional parameters in a cascading group here.

iReport - Concatenating two variables with different evaluation time

I have two variables
$V{from} has evaluation value set to Now and
$V{to} has evaluation value set to Group.
Both seems to be working fine.
Now I need to append them. Currently I have $V{fromTo} which has expression $V{from} + "-" + $V{to}. Its evaluation time value is Group. What I want is just to simply append the current values of the two first mentioned variables. The current expression gives me the result (e.g. from = 1, to = 45)
45-45
Seems like the expression is taking the value of $V{from} evaluated during group execution time also. Any idea how to do this?
(Note, requirement does not allow me to just simply drag the two fields, i badly needed to store it in one variable)
I had the same problem. I solved setting Evaluation Time to Auto in my Text Field.

Text input through SSRS parameter including a Field name

I have a SSRS "statement" type report that has general layout of text boxes and tables. For the main text box I want to let the user supply the value as a parameter so the text can be customized, i.e.
Parameters!MainText.Value = "Dear Mr.Doe, Here is your statement."
then I can set the text box value to be the value of the parameter:
=Parameters!MainText.Value
However, I need to be able to allow the incoming parameter value to include a dataset field, like so:
Parameters!MainText.Value = "Dear Mr.Doe, Here is your [Fields!RunDate.Value] statement"
so that my report output would look like:
"Dear Mr.Doe, Here is your November statement."
I know that you can define it to do this in the text box by supplying the static text and the field request, but I need SSRS to recognize that inside the parameter string there is a field request that needs to be escaped and bound.
Does anyone have any ideas for this? I am using SSRS 2008R2
Have you tried concatenating?
Parameters!MainText.Value = "Dear Mr.Doe, Here is your" & [Fields!RunDate.Value] & "statement"
There are a few dramatically different approaches. To know which is best for you will require more information:
Embedded code in the report. Probably the quickest to
implement would be embedded code in the report that returned the
parameter, but called String.Replace() appropriately to substitute
in dynamic values. You'll need to establish some code for the user for which strings will be replaced. Embedded code will get you access to many objects in the report. For example:
Public Function TestGlobals(ByVal s As String) As String
Return Report.Globals.ExecutionTime.ToString
End Function
will return the execution time. Other methods of accessing parameters for the report are shown here.
1.5 If this function is getting very large, look at using a custom assembly. Then you can have a better authoring experience with Visual Studio
Modify the XML. Depending on where you use
this, you could directly modify the .rdl/.rdlc XML.
Consider other tools, such as ReportBuilder. IF you need to give the user
more flexibility over report authoring, there are many tools built
specifically for this purpose, such as SSRS's Report Builder.
Here's another approach: Display the parameter string with the dataset value already filled in.
To do so: create a parameter named RunDate for example and set Default value to "get values from a query" and select the first dataset and value field (RunDate). Now the parameter will hold the RunDate field and you can use it elsewhere. Make this parameter hidden or internal and set the correct data type. e.g. Date/Time so you can format its value later.
Now create the second parameter which will hold the default text you want:
Parameters!MainText.Value = "Dear Mr.Doe, Here is your [Parameters!RunDate.Value] statement"
Not sure if this syntax works but you get the idea. You can also do formatting here e.g. only the month of a Datetime:
="Dear Mr.Doe, Here is your " & Format(Parameters!RunDate.Value, "MMMM") & " statement"
This approach uses only built-in methods and avoids the need for a parser so the user doesn't have to learn the syntax for it.
There is of course one drawback: the user has complete control over the parameter contents and can supply a value that doesn't match the report content - but that is also the case with the String Replace method.
And just for the sake of completeness there's also the simplistic option: append multiple parameters: create 2 parameters named MainTextBeforeRunDate and MainTextAfterRunDate.
The Textbox value expression becomes:
=Parameters!MainTextBeforeRunDate.Value & Fields!RunDate.Value & Parameters!MainTextAfterRunDate.Value.
This should explain itself. The simplest solution is often the best, but in this case I have my doubts. At least this makes sure your RunDate ends up in the final report text.