How can I remove whitespace between static text elements on the same row? [duplicate] - jasper-reports

Can nay one help to add multiple DB field values in one field.
Say i have 3 DB fields:
Name
Address
Age
I want to display all 3 fields in the same field:
John Peter 28.
I tried doing 3 fields next to each other and it did work but when i wrap text. It looks really bad:
Name
Jo.pe.28
hn te
r
My requirement is show data in one text field, for example: John.Peter.26

If you want to put them in one line (which i guess is the case), its straight forward.
Put this as a text box $F{Name} + "." + $F{Address} + "." + $F{Age}.toString()
Or you can use string concatenation (I dont personally like the syntax, take more effort to understand) $F{Name}.concat(".").concat($F{Address}).concat(".").concat($F{Age})

The SQL Method
Why not concatenate all the 3 fields you need in the query you use itself like (Assuming you are with Postgres.),
select (name || address|| to_char(age)) as data from my_table
In Ireport
As suggested,
$F{Name} + "." + $F{Address} + "." + $F{Age}.toString()
too works if needed to make it work from the report.
Make sure that all your fields are of same data type.

Related

Find rows where string contains certain character at specific place

I have a field in my database, that contains 10 characters:
Fx: 1234567891
I want to look for the rows where the field has eg. the numbers 8 and 9 in places 5 and 6
So for example,
if the rows are
a) 1234567891
b) 1234897891
c) 1234877891
I only want b) returned in my select.
The type of the field is string/character varying.
I have tried using:
where field like '%89%'
but that won't work, because I need it to be 89 at a specific place in the string.
The fastest solution would be
WHERE substr(field, 8, 2) = '89'
If the positions are not adjacent, you end up with two conditions joined with AND.
You should be able to evaluate the single character using the underscore(_) character. So you should be able to use it as follows.
where field like '____89%'

Split string into two parts and concatenate with another column

My string columns look like this:
Name : AllenEdward
UniqID : 12345678
How can I get this output in my report?
Allen12345678 Edward
12345678 should be followed by 2 spaces.
The first thing to figure out the formulas that split the Name column. We don't know what your data looks like, so that's all you. You could write something that adds a space before any capital letters after the first, but you'll have trouble with the more complex last names like MacDonald.
Once you figure that out, it's a simple matter of using Formula Fields in Crystal. Something like:
[FIRST]{table.UniqID} & " " & [LAST]
...where [FIRST] and [LAST] are the results from your splitting formula.

Print fields being browsed on the screen

I need to write a FM script which print one field of the records being browsed on the screen and separated by commas.However, I do not know how to select the records being currently browsed and am not able to find it in the documentation (the lack of the good keyword could be the problem).
Thank you!
It sounds like you're trying to create a list of all values for one field in the Found Set. FileMaker 13 introduced the List of Summary type, which makes this pretty easy:
First, create a Summary field, say FoundAddresses. Make it a List of your e-mail address field. This field will contain a return-delimited list of the e-mail addresses in the Found Set.
Second, create a Calculation field, say FoundAddressesCommaDelimited. Make it the following text Calculation:
Substitute (
GetSummary ( FoundAddresses ; FoundAddresses ) ;
ΒΆ ; ", "
)
This will substitute all of the returns in FoundAddresses for comma-space.

How to show several fields values in one textField

Can nay one help to add multiple DB field values in one field.
Say i have 3 DB fields:
Name
Address
Age
I want to display all 3 fields in the same field:
John Peter 28.
I tried doing 3 fields next to each other and it did work but when i wrap text. It looks really bad:
Name
Jo.pe.28
hn te
r
My requirement is show data in one text field, for example: John.Peter.26
If you want to put them in one line (which i guess is the case), its straight forward.
Put this as a text box $F{Name} + "." + $F{Address} + "." + $F{Age}.toString()
Or you can use string concatenation (I dont personally like the syntax, take more effort to understand) $F{Name}.concat(".").concat($F{Address}).concat(".").concat($F{Age})
The SQL Method
Why not concatenate all the 3 fields you need in the query you use itself like (Assuming you are with Postgres.),
select (name || address|| to_char(age)) as data from my_table
In Ireport
As suggested,
$F{Name} + "." + $F{Address} + "." + $F{Age}.toString()
too works if needed to make it work from the report.
Make sure that all your fields are of same data type.

Sorting a Drop-down (value) list by second field that's not displayed

How can I have a drop-down (value) list sorted by a second field (sortId) without showing that field? (I also want to include a "separator line".)
My current solution uses a second field of whitespaces to sort, but this leads to unfortunate behaviour.
Problem:
As the list needs to be dynamic (i.e. read from a table) I cannot use a Custom Value List.
The list should look like this:
zzz (sortId = 1)
aaa (sortId = 2)
bbb (sortId = 3)
------------------- (Does maybe also have to be defined with a sortId..)
uuu (sortId = 4)
lll (sortId = 5)
rrr (sortId = 6)
But the sortId should not be displayed in the drop-down list.
What I tried:
Since drop-down lists get sorted alphabetically I found out that there is this trick with using a second field which
contains "whitespaces" as sorting order. With a script/command:
Substitute(10^sortId - 1, "9", " ")
I am able to convert sortId into the correct amount of whitespaces. The sorting then works...
However, whitespaces are still shown in the Drop-down list and because we have maybe around 100 items in the value list it expands the drop-down to the right.
Another problem is that we need to use the "-" as separator line, but with this approach the "-" does not get replaced by the separator line, because the blank whitespaces are still filled behind it so its "- " and this
does not get replaced by the separator line.
I believe this technique is similar to what you've already tried, only it uses a 0-width Byte Order Mark, Char 65279:
http://www.soliantconsulting.com/blog/2012/09/extending-filemaker-pro%E2%80%99s-value-list-sort-capabilities-using-char-function
It won't give you functionality for the separator line, but you should be able to get a sortable list this way.