Jump to content
  • 0
Elena

Stuff Text Function

Question

Hello Jan it's me again,

 

I have these strings in the calculated field, that I wish to put commas followed by spaces in between them.

 

I tried simply putting a plus sign to add up the fields, it works, but whenever a field is empty, I am left with the "commas" and the "spaces" showing in the results.

 

My question is:  Shoud I be using the STUFF and SPACE function to put a comma and a space?   Such comma or space should not show whenever there is nothing to use comma or space for.  Is there any other way?

 

Here below is what I have. Probably not a good practice at all.

 

 

[@field:Server]+', '+[@field:Training]+', '+[@field:Telecom]+', '+[@field:Hardware]+', '+[@field:Software]

 

 

Results:

Server Technology, Education & Training , , ,
 

 

The fields Telecom, Hardware, Software are all left empty by the user. The results are showing only the commas and the spaces that I added up.

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hello Elena,

 

I think, I have found a possible solution.

 

It's needed four Calculated fields that will define to display a comma or not.

 

First field:

CASE
WHEN [@field:Server]!='' AND ([@field:Training]!='' OR [@field:Telecom]!='' OR [@field:Hardware]!='' OR [@field:Software]!='') THEN ', '
ELSE ''
END

Second field:

CASE
WHEN [@field:Training]!='' AND ([@field:Telecom]!='' OR [@field:Hardware]!='' OR [@field:Software]!='') THEN ', '
ELSE ''
END

Third field:

CASE
WHEN [@field:Telecom]!='' AND ([@field:Hardware]!='' OR [@field:Software]!='') THEN ', '
ELSE ''
END

Fourth field:

CASE
WHEN [@field:Hardware]!='' AND ([@field:Software]!='') THEN ', '
ELSE ''
END

Now you can enter value of these fields instead ", ":

[@field:Server]+[@calcfield:1]+[@field:Training]+[@calcfield:2]+ [@field:Telecom]+[@calcfield:3]+[@field:Hardware]+[@calcfield:4]+[@field:Software]

Please, enter your numbers for every Calculated field instead of [@calcfield:N]

 

And now you can add the Footer element and add the following code to hide additional Calculated fields:

<script language="javascript" type="text/javascript">
function hide_column(column_order)
{
     var tbl = document.getElementsByTagName("table")[0];
     var table_header = tbl.getElementsByTagName('th')[column_order];
     table_header.style.display=stl;
     var rows = tbl.getElementsByTagName('tr');
     for (var row=1; row<rows.length;row++)
        {     
            var cels = rows[row].getElementsByTagName('td');
            cels[column_order].style.display=stl;
        }
}

var stl='none';
hide_column(0);
hide_column(1);
hide_column(2);
hide_column(3);
</script>

0,1,2,3 - are numbers of columns with Calculated fields. I placed them at the beginning of the table.

 

I am not sure that it is the best solution.

I hope it works.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×