Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return the count of delimiters in a string

Status
Not open for further replies.

huytonscouser

Programmer
Oct 14, 2011
88
US
i have a string field "WMKHPMD019A,WMKHPMD019B,WMKHPMA081A,WMKHPMA081B,WFLLPSSPDB01,WFLLPSSPDB02"

is there a formula to return the count of commas(delimiters), (5) in this string ?

Thanks
 
ubound(split({textfieldcontasiningdelimeter},",")-1

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
I have placed this formula(@count hosts) in the group header 1 section :-

if ISNULL({SRMHOST.SHAREDHOSTLIST}) THEN 1
ELSE
ubound(split({SRMHOST.SHAREDHOSTLIST},","))

It works fine, but in a formula in the details section, i only want to use the @count hosts value once, and not for all the records that make up the group.

If "AIX" IN GroupName ({SRMHOST.HOSTOS}) THEN
(
TOTAL_OS :=TOTAL_OS+{@count hosts };
TOTAL_AIX :=TOTAL_AIX+{@count hosts };
TOTAL_MINNEAPOLIS_AIX := TOTAL_MINNEAPOLIS_AIX +{@count hosts };
TOTAL_FS :=TOTAL_FS+{@FS size GB};
TOTAL_MINNEAPOLIS_FS := TOTAL_MINNEAPOLIS_FS+{@FS size GB};
TOTAL_FS_MINNEAPOLIS_AIX := TOTAL_FS_MINNEAPOLIS_AIX+{@FS size GB} ;


How can i modify the formula in details section to only use @count hosts once when processing same group ?
 
I assume {SRMHOST.SHAREDHOSTLIST} potentially has a different value for each record in the group.
Which record in the group do you want the value of {@count hosts} ?
Is the value you get in the header the correct value (every time) that you need for each record?







_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
I assume {SRMHOST.SHAREDHOSTLIST} potentially has a different value for each record in the group.

No, not when its in the group, {SRMHOST.SHAREDHOSTLIST} is the same for all records in the group.

Which record in the group do you want the value of {@count hosts} ?

Doesn't matter, just need it to reflect the value once(for the group), or zero.

Is the value you get in the header the correct value (every time) that you need for each record?

Yes it is, the value in the group header is always the one i need in the record's


Thanks in advance,








 
If you could describe your output requirements a little it might help. There are also some options which would allow you to include output in this message as an attachment. Also, if you dont mid, paste the entire formula you referenced above. The part you showed, assigned values to several variables and seeing the rest of that formula may be helpful.



_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
What i'm trying to achieve is to create a stack of subreports, each the same but for different locations(data sources), then in a final report, create graphs, charts, totals from the subreports, using shared variables from each of the seperate subreports.


Each subreport has this formula, depending upon location, this is for Minneapolis :-
SHARED numbervar TOTAL_OS;
SHARED numbervar TOTAL_AIX;
SHARED numbervar TOTAL_WINDOWS;
SHARED numbervar TOTAL_LINUX;
SHARED numbervar TOTAL_SOLARIS;
SHARED numbervar TOTAL_OTHER;

SHARED numbervar TOTAL_FS;
SHARED numbervar TOTAL_FS_AIX;
SHARED numbervar TOTAL_FS_WINDOWS;
SHARED numbervar TOTAL_FS_LINUX;
SHARED numbervar TOTAL_FS_SOLARIS;
SHARED numbervar TOTAL_FS_OTHER;


SHARED numbervar TOTAL_MINNEAPOLIS_OS;
SHARED numbervar TOTAL_MINNEAPOLIS_AIX;
SHARED numbervar TOTAL_MINNEAPOLIS_WINDOWS;
SHARED numbervar TOTAL_MINNEAPOLIS_LINUX;
SHARED numbervar TOTAL_MINNEAPOLIS_SOLARIS;
SHARED numbervar TOTAL_MINNEAPOLIS_OTHER;

SHARED numbervar TOTAL_MINNEAPOLIS_FS;
SHARED numbervar TOTAL_FS_MINNEAPOLIS_AIX;
SHARED numbervar TOTAL_FS_MINNEAPOLIS_WINDOWS;
SHARED numbervar TOTAL_FS_MINNEAPOLIS_LINUX;
SHARED numbervar TOTAL_FS_MINNEAPOLIS_SOLARIS;
SHARED numbervar TOTAL_FS_MINNEAPOLIS_OTHER;



if onlastrecord and previous({@Sort metric}) <> {@Sort metric}
or
{@Sort metric} <> next({@Sort metric}) then


If "AIX" IN GroupName ({SRMHOST.HOSTOS}) THEN
(
TOTAL_OS :=TOTAL_OS+{@count hosts };
TOTAL_AIX :=TOTAL_AIX+{@count hosts };
TOTAL_MINNEAPOLIS_AIX := TOTAL_MINNEAPOLIS_AIX +{@count hosts };
TOTAL_FS :=TOTAL_FS+{@FS size GB};
TOTAL_MINNEAPOLIS_FS := TOTAL_MINNEAPOLIS_FS+{@FS size GB};
TOTAL_FS_MINNEAPOLIS_AIX := TOTAL_FS_MINNEAPOLIS_AIX+{@FS size GB} ;

)

else if "WINDOWS" IN GroupName ({SRMHOST.HOSTOS}) THEN
(
TOTAL_OS :=TOTAL_OS+{@count hosts };
TOTAL_WINDOWS :=TOTAL_WINDOWS+{@count hosts };
TOTAL_MINNEAPOLIS_WINDOWS := TOTAL_MINNEAPOLIS_WINDOWS +{@count hosts };
TOTAL_FS :=TOTAL_FS+{@FS size GB};
TOTAL_MINNEAPOLIS_FS := TOTAL_MINNEAPOLIS_FS+{@FS size GB};
TOTAL_FS_MINNEAPOLIS_WINDOWS := TOTAL_FS_MINNEAPOLIS_WINDOWS+{@FS size GB} ;

)


else if "LINUX" IN GroupName ({SRMHOST.HOSTOS}) THEN
(
TOTAL_OS :=TOTAL_OS+{@count hosts };
TOTAL_LINUX :=TOTAL_LINUX+{@count hosts };
TOTAL_MINNEAPOLIS_LINUX := TOTAL_MINNEAPOLIS_LINUX +{@count hosts };
TOTAL_FS :=TOTAL_FS+{@FS size GB};
TOTAL_MINNEAPOLIS_FS := TOTAL_MINNEAPOLIS_FS+{@FS size GB};
TOTAL_FS_MINNEAPOLIS_LINUX := TOTAL_FS_MINNEAPOLIS_LINUX+{@FS size GB} ;
)
else if "SOLARIS" IN GroupName ({SRMHOST.HOSTOS}) THEN
(
TOTAL_OS :=TOTAL_OS+{@count hosts };
TOTAL_SOLARIS :=TOTAL_SOLARIS+{@count hosts };
TOTAL_MINNEAPOLIS_SOLARIS := TOTAL_MINNEAPOLIS_SOLARIS +{@count hosts };
TOTAL_FS :=TOTAL_FS+{@FS size GB};
TOTAL_MINNEAPOLIS_FS := TOTAL_MINNEAPOLIS_FS+{@FS size GB};
TOTAL_FS_MINNEAPOLIS_SOLARIS := TOTAL_FS_MINNEAPOLIS_SOLARIS+{@FS size GB} ;
)
else
(
TOTAL_OS :=TOTAL_OS+{@count hosts };
TOTAL_OTHER :=TOTAL_OTHER+{@count hosts };
TOTAL_MINNEAPOLIS_OTHER := TOTAL_MINNEAPOLIS_OTHER +{@count hosts };
TOTAL_FS :=TOTAL_FS+{@FS size GB};
TOTAL_MINNEAPOLIS_FS := TOTAL_MINNEAPOLIS_FS+{@FS size GB};
TOTAL_FS_MINNEAPOLIS_OTHER := TOTAL_FS_MINNEAPOLIS_OTHER+{@FS size GB} ;
)

This is a trimmed example of output :

WFLLPCRDSUP01 Windows Server 2003 5.2 1.00
1,499.99 1.00 1
5,999.99 1.00 0
999.99 1.00 0
2,999.63 1.00 0
11,499.59
WSDMD501,WSLCD106DB Windows Server 2003 5.2 2.00
15.63 2.00 2
999.00 2.00 0
189.37 2.00 0
20.00 2.00 0
4,080.00 2.00 0
2,047.96 2.00 0
1,032.99 2.00 0



The last value in the group header 1.00 or 2.00 is what i need to add just once, when you see in the records , the 1.00 or 2.oo is duplicated, and i need it 1/0 or 2/0 in each record.

 
I hate working with sub reports and avoid it all costs. I am usually successful at figuring a way around them. But I digress. Your issue is not sub report related.

You are going to have to bare with me because I remain confused...

WSDMD501,WSLCD106DB Windows Server 2003 5.2 2.00
15.63 2.00 2
999.00 2.00 0
189.37 2.00 0
20.00 2.00 0

There are 4 separate records for WSDMD501,WSLCD106DB Windows Server 2003 ?
I understand the formula but what field or fields are you placing in the details section to create that output?

"The last value in the group header 1.00 or 2.00 is what i need to add just once," on which record?









_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
I thank you for your help, i know it's confusing.

The issue is not sub-report related, the issue is how do i sum up the number of hosts
in the records for the group only once,

In this example

WSDMD501,WSLCD106DB Windows Server 2003 5.2 2.00
15.63 2.00 2
999.00 2.00 0
189.37 2.00 0
20.00 2.00 0

I only want to add to EACH of these variables once for the group :-
TOTAL_OS :=TOTAL_OS+{@count hosts };
TOTAL_OS_WINDOWS :=TOTAL_OS_WINDOWS+{@count hosts };
TOTAL_MINNEAPOLIS_WINDOWS := TOTAL_MINNEAPOLIS_WINDOWS +{@count hosts };

I think the consgusion was caused by me manually adding the data to visually show what i get.

This is currenly what i have, with 2.0 ({@count hosts }) added to group header.

WSDMD501,WSLCD106DB Windows Server 2003 5.2 2.00
15.63
999.00
189.37
20.00

Only 1 metric in details section {@FS size GB}.
 
try this .. with my lack of understanding its all I have!

in your formula add another variable declaration
numbervar numhosts;
after the declarations and before the first if statement


if recordnumber = 1 then numhosts := {@count hosts }
else if {Call_Logging_Audit.Call_Type} <> previous({Call_Logging_Audit.Call_Type}) then numhosts := {@count hosts }
else numhosts := 0;

then replace {@count hosts } with numhosts in your formulas.




_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
whups

if recordnumber = 1 then numhosts := {@count hosts }
else if {SRMHOST.HOSTOS} <> previous({SRMHOST.HOSTOS}) then numhosts := {@count hosts }
else numhosts := 0;

previous post was from me testing .. I forgot to change the fields

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Thank you very much, a small modification was needed in my report, but you placed me on the right path. [2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top