Jump to content
  • 0

Stuff Text Function


Elena

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.

 

 

 

 

 

 

 

 

Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...