DataWindow Expression - Count a Value of a Column

Hello all!

How can I implement a "countIf"-Computed Field? This Computed Field 
should based on a Value of a Column and it should count, how often the 
value appears in the column.

for example:

Text	countIf
----	-------
"aaa"	1	(... the String "aaa" appears 1x)
"bbb"	2	(... the String "bbb" appears 2x)
"ccc"	3	(... the String "ccc" appears 3x)
"ccc"	3	(... the String "ccc" appears 3x)
"ccc"	3	(... the String "ccc" appears 3x)
"bbb"	2	(... the String "bbb" appears 2x)


The following expression counts how often the text 'bbb' occurs.
	countIf = "Sum( If( text  = 'bbb', 1, 0 ))"
But I want an expression that count each Item in the 'text'-Column ... 
not a special.

Thanks in advance.
Stephan B.
0
Stephan
6/28/2004 1:02:05 PM
sybase.powerbuilder.general 62418 articles. 19 followers. Follow

5 Replies
2159 Views

Similar Articles

[PageSpeed] 15
Get it on Google Play
Get it on Apple App Store

If you don't have a known set of values, look into the Crosstab DW style.

"Stephan Beck" <stb@nodomain.de> wrote in message
news:40e0176c$1@forums-2-dub...
> Hello all!
>
> How can I implement a "countIf"-Computed Field? This Computed Field
> should based on a Value of a Column and it should count, how often the
> value appears in the column.
>
> for example:
>
> Text countIf
> ---- -------
> "aaa" 1 (... the String "aaa" appears 1x)
> "bbb" 2 (... the String "bbb" appears 2x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "bbb" 2 (... the String "bbb" appears 2x)
>
>
> The following expression counts how often the text 'bbb' occurs.
> countIf = "Sum( If( text  = 'bbb', 1, 0 ))"
> But I want an expression that count each Item in the 'text'-Column ...
> not a special.
>
> Thanks in advance.
> Stephan B.


0
Jerry
6/28/2004 2:28:21 PM
You could create a GROUP based on that column, and then use CumulativeSum( 1 for group n)

-- 
Paul Horan[TeamSybase]

"Stephan Beck" <stb@nodomain.de> wrote in message news:40e0176c$1@forums-2-dub...
> Hello all!
>
> How can I implement a "countIf"-Computed Field? This Computed Field
> should based on a Value of a Column and it should count, how often the
> value appears in the column.
>
> for example:
>
> Text countIf
> ---- -------
> "aaa" 1 (... the String "aaa" appears 1x)
> "bbb" 2 (... the String "bbb" appears 2x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "bbb" 2 (... the String "bbb" appears 2x)
>
>
> The following expression counts how often the text 'bbb' occurs.
> countIf = "Sum( If( text  = 'bbb', 1, 0 ))"
> But I want an expression that count each Item in the 'text'-Column ...
> not a special.
>
> Thanks in advance.
> Stephan B.


0
Paul
6/28/2004 3:04:37 PM
Try this for your expression, replacing "mycolumn" with the name of the
column with the text:

describe('evaluate("Sum( If( mycolumn  = ~'' + mycolumn + '~', 1, 0 ))",
1)')


Ken


"Stephan Beck" <stb@nodomain.de> wrote in message
news:40e0176c$1@forums-2-dub...
> Hello all!
>
> How can I implement a "countIf"-Computed Field? This Computed Field
> should based on a Value of a Column and it should count, how often the
> value appears in the column.
>
> for example:
>
> Text countIf
> ---- -------
> "aaa" 1 (... the String "aaa" appears 1x)
> "bbb" 2 (... the String "bbb" appears 2x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "ccc" 3 (... the String "ccc" appears 3x)
> "bbb" 2 (... the String "bbb" appears 2x)
>
>
> The following expression counts how often the text 'bbb' occurs.
> countIf = "Sum( If( text  = 'bbb', 1, 0 ))"
> But I want an expression that count each Item in the 'text'-Column ...
> not a special.
>
> Thanks in advance.
> Stephan B.


0
Ken
6/28/2004 3:22:16 PM
Hi Ken.

Your Computed Field works nearly perfect. But when I try to get the 
maximum of this computed field or when I try to sort this computed field 
my program/the PB-IDE crashes with a an error.

I changed your code a little bit, but I get every time (PB9.0.1 Build 
7096 and PB 8.0.3 Build 9704) the same result... 
describe('evaluate("Sum( If( mycolumn  = ~'' + mycolumn + '~', 1, 0 ))", 
'+string(getRow())+')')


Stephan B.

Ken Balakrishnan wrote:

> Try this for your expression, replacing "mycolumn" with the name of the
> column with the text:
> 
> describe('evaluate("Sum( If( mycolumn  = ~'' + mycolumn + '~', 1, 0 ))",
> 1)')
> 
> 
> Ken
> 
> 
> "Stephan Beck" <stb@nodomain.de> wrote in message
> news:40e0176c$1@forums-2-dub...
> 
>>Hello all!
>>
>>How can I implement a "countIf"-Computed Field? This Computed Field
>>should based on a Value of a Column and it should count, how often the
>>value appears in the column.
>>
>>for example:
>>
>>Text countIf
>>---- -------
>>"aaa" 1 (... the String "aaa" appears 1x)
>>"bbb" 2 (... the String "bbb" appears 2x)
>>"ccc" 3 (... the String "ccc" appears 3x)
>>"ccc" 3 (... the String "ccc" appears 3x)
>>"ccc" 3 (... the String "ccc" appears 3x)
>>"bbb" 2 (... the String "bbb" appears 2x)
>>
>>
>>The following expression counts how often the text 'bbb' occurs.
>>countIf = "Sum( If( text  = 'bbb', 1, 0 ))"
>>But I want an expression that count each Item in the 'text'-Column ...
>>not a special.
>>
>>Thanks in advance.
>>Stephan B.
> 
> 
> 
0
Stephan
6/29/2004 9:12:52 AM
Yipes, I see what you mean.  Seems to be a problem whenever the expression
includes an aggregate function inside a describe(evaluate(...)).  If you're
going to be sorting by the text field anyway, you might try Paul Horan's
suggestion instead; if you want to stick with this, one rather cumbersome
workaround would be to add a column to the datawindow, and then in code,
move the data from the computed field to the extra column, e.g.

dw_1.object.newcolumn.primary = dw_1.object.compute_1.primary

Then PB will let you sort by the new column.

Good luck,
Ken

"Stephan Beck" <stb@nodomain.de> wrote in message
news:40e13334@forums-2-dub...
> Hi Ken.
>
> Your Computed Field works nearly perfect. But when I try to get the
> maximum of this computed field or when I try to sort this computed field
> my program/the PB-IDE crashes with a an error.
>
> I changed your code a little bit, but I get every time (PB9.0.1 Build
> 7096 and PB 8.0.3 Build 9704) the same result...
> describe('evaluate("Sum( If( mycolumn  = ~'' + mycolumn + '~', 1, 0 ))",
> '+string(getRow())+')')
>
>
> Stephan B.
>
> Ken Balakrishnan wrote:
>
> > Try this for your expression, replacing "mycolumn" with the name of the
> > column with the text:
> >
> > describe('evaluate("Sum( If( mycolumn  = ~'' + mycolumn + '~', 1, 0 ))",
> > 1)')
> >
> >
> > Ken
> >
> >
> > "Stephan Beck" <stb@nodomain.de> wrote in message
> > news:40e0176c$1@forums-2-dub...
> >
> >>Hello all!
> >>
> >>How can I implement a "countIf"-Computed Field? This Computed Field
> >>should based on a Value of a Column and it should count, how often the
> >>value appears in the column.
> >>
> >>for example:
> >>
> >>Text countIf
> >>---- -------
> >>"aaa" 1 (... the String "aaa" appears 1x)
> >>"bbb" 2 (... the String "bbb" appears 2x)
> >>"ccc" 3 (... the String "ccc" appears 3x)
> >>"ccc" 3 (... the String "ccc" appears 3x)
> >>"ccc" 3 (... the String "ccc" appears 3x)
> >>"bbb" 2 (... the String "bbb" appears 2x)
> >>
> >>
> >>The following expression counts how often the text 'bbb' occurs.
> >>countIf = "Sum( If( text  = 'bbb', 1, 0 ))"
> >>But I want an expression that count each Item in the 'text'-Column ...
> >>not a special.
> >>
> >>Thanks in advance.
> >>Stephan B.
> >
> >
> >


0
Ken
6/29/2004 1:20:07 PM
Reply:

Similar Artilces:

Setting the value of columns in Datawindow Expressions
Is it possible to set the value of a column in a datawindow expression. I have used the gettext to get the value of a column but can I set it. I would prefer coding code within the datawindow than to write script for this. Thanks in advance No. You can set the default value for a newly inserted row in the column specifications, but that allows only constants, not expressions. Derrick Chan wrote in message ... >Is it possible to set the value of a column in a datawindow expression. I >have used the gettext to get the value of a column but can I set it. I >would p...

Datawindow Displays Data Column Names and Expressions instead of Values
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C81CA9.C4458400 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable The following expression is used for the VISIBLE expression on 4 data = columns: IF(evaluate_subject =3D 'Ending Backlog' OR left(report_type, 4) IN = ('SOLD', 'UNSO'), 0, 1) The expression validates as VALID. However, when the datawindow is = generated and data placed into it, when displayed on screen, it displays = not the data but all the data column headers an...

How to get a column property in a datawindow column object expression?
Hi, I have a free style datawindow, I want such expression: columnA.x = IF(columnB.visible, columnB.x + 100, 200) Yes, you can get it in script, but I just want set it in datawindow. Anyone can help? Bo Song soong@188.net Hi Bo, AFAIK, you cannot reference object properties in the expression. That would be nice... -- - Eric Aling [TeamPS], Cypres Informatisering bv, The Netherlands Eric's Home & PB Site @ http://utopia.knoware.nl/users/cypr115 Bo Song <soong@188.net> wrote in message 36D52106.433CE9B2@188.net... >Hi, >I have a free style data...

get column value in DW expression without column name
Hi everyone! I've got a common experssion that I'd like to put on every bold column property: I'd like set the column font to bold if the previous column value is equal to the current. As I have many columns, even dynamic columns, I don't know their name in order to set an expression like this: "if (col_name = col_name[-1], ...)" So any idea? Hi Matthieu, get all object names using the expression "datawindow.objects", split this tab separated list into single object names, check every object wether it is a column using the expression &quo...

How to Modify Contents of a DataWindow DDLB column based on value of another column in the same row.
I'm trying to conditionally Modify the contents of a DataWindow DDLB column. For example, ls_modstr = "cp_basis.Values='5 Test~t5~tIf(cp_type=~~'TB~~',30 Day~t30,3 Year~t3)'" ls_rtn = This.Modify(ls_modstr) Does anyone have an example of syntax that works? Thanks, George I don't believe the values attribute will actually accept a function. Have you thought about using a DDDW instead and applying a filter dynamically? On Wed, 20 Feb 2002 11:10:21 -0500, in powersoft.public.powerbuilder.datawindow <George_Farrance> wrote: >...

Datawindow Expression value
How do I get the actual value of an expression? for example dw_1.columnname.Protect value = dw_1.columnname.Protect if value = 0 then // do this else // do that end if Use the evaluate keyword. <Josiah Ward> wrote in message news:46362535.3b1c.1681692777@sybase.com... > How do I get the actual value of an expression? > for example dw_1.columnname.Protect > > value = dw_1.columnname.Protect > > if value = 0 then > // do this > else > // do that > end if ...

visible expression for columns in a datawindow
Hi, I hope there is anybody who can solve the following problem: I want to make a column in a datawindow invisible. So I have inserted the value 0 into the visible expression of the column. If I make a preview of the datawindow the column is really invisible. Great! But if I insert this datawindow into a composite datawindow and make a preview then the column is visible. Has the visible expression no effect? Any ideas??? Would it help to set the width to be 0 (maybe the height too) Does the composite alway show the dw the way it is presented in the dw painter rat...

Initial values for columns in datawindow
I have a button in a datawindow that appends a row which works fine. What I would like to happen is have some columns have an initial value. These initial values will vary based on the arguments to the SELECT statement used to retrieve the existing rows. Can I use the arguments or global variables to set these without putting code in the buttonclicked event? Thanks Don you can change the initial value with pb scripts, e.g.: dw_1.object.columnname.initial = "abc" see Initial DataWindow object property for details. "Don" <dmcquade@dmapros.com> �b�l...

Defining an expression for a datawindow column
Hello, I want to define an expression for the 'Protect' attribute of a datawindow column. I need to use a global variable in this expression. Is this not possible ? Am I allowed to build the expression using only the columns listed in the 'Modify Expression' box ? TIA, Ganesh You can use a global function in a Datawindow expression. This function can return the value of the global variable. jiggy ________________________________________________________________________ If everything seems to be going well, you have obviously overlooked something. eMail: j...

expressions to change column values
Hello all, I was wondering if anyone knows if it is possible to use the text of one column to determine the text of another column. Example. Column A has a value of "-2". I would like to put in an expression that says if( a.Text = "-2", b.Text = "New Value", b.Text = "Original Value" ). I tried putting that exact code in the expression( don't remember which one ), but it didn't work. Has anyone done this or knows how? Thanks Mel Haynes Jr Retail Solutions Group, LLC mhaynesjr@pcisys.net A column can be accessed in an exp...

Choosing between two column values to return as single column value
I'm working on a social network where I store my friend GUIDs in a table with the following structure:user1_guid       user2_guidI am trying to write a query to return a single list of all a users' friends in a single column.  Depending on who initiates the friendship, a users' guid value can be in either of the two columns.  Here is the crazy sql I have come up with to give what I want, but I'm sure there's a better way...  Any ideas?SELECT DISTINCT UserIdFROM espace_ProfilePropertyWHERE (UserId IN ...

SetNull to a column value in a Datawindows
Hello. I�m trying to use the set null value for column in a datawindows. The problem is that i have a datawindow external with two columns, each one of this columns contain a datawindow child. These make a function like a master detail. one dwChild(dwchild1) is referenced to a table product_group and the other one(dwchild2) to a table product. When i get the selecci�n of the group in the itemchanged event of the dwchild1 the retrieve is executed with one retrieval argument (group), and the list of product filtered out by the group selected is show up. I need to clear the val...

column status in datawindow expression
How can i check the status of a column in a datawindow expression On 19 Mar 2006 04:01:27 -0800, "Sukhvinder Singh" <sukhvinder@defactoinfotech.com> wrote: >How can i check the status of a column in a datawindow expression > For rows there are functions IsRowNew() and IsRowModified(). There are no equivalent functions for the columns, but you can access the column original value through dot notation: column_name.original So you could do something like IF (column_name = column_name.original, "NotModified", "DataModified or Null&...

Matching each value out of multiple values to single column value
 Hi,  @whoposted in stored procedure holds value "agent  builder owner"  ( please note the space in between) My column  POSTED_BY  always holds one and only one value out of above 3.Example:       POSTED_BY  owneragent          etc... If  All / any of the value hold by  @whoposted matches with value of POSTED_BY column, i want to show that row in gridview.( Also, please note, str may hold different values depending on user selection. For example, it may ...

How passing values to hidden DataWindows columns
Hello, I build a DataWindow (DW) to create new data records, but some values are constant or PageParameters from previous called html sites. How can I transmit this data to hidden columns of the DW. The hidden columns needs to be not NULL when I click the CREATE-Button. Is there a standard way without modifiying DW-Code manually after generation? Are there examples for this task? Karl-Heinz, you could use callback functions to achieve what you want. If you check the "Enable User Callbacks" box on the "Context" tab of the DTC object PowerSite generate...

Web resources about - DataWindow Expression - Count a Value of a Column - sybase.powerbuilder.general

PowerBuilder - Wikipedia, the free encyclopedia
PowerBuilder is an integrated development environment owned by Sybase , a division of SAP . It has been in use since 1991, peaking around 1998 ...

Intelligent Versus Surrogate Keys
Should I use business columns as primary key fields for tables in thedatabase, or generate artificial primary key values? When business-related ...

chevy volt
ProEXR File Description =Attributes= channels (chlist) compression (compression): Zip dataWindow (box2i): [0, 0, 5119, 2475] displayWindow (box2i): ...

Enable - A comprehensive solution for the localization of PowerBuilder applications Untitled Document ...
Enable is localization/ translation tool used by PowerBuilder developers to make their applications multilingual.Enable is a powerful tool that ...

comp.lang.clipper.visual-objects - Google Groups
comp.lang.clipper.visual-objects 1-20 von 33006 Themen werden angezeigt Integrity of a file marcosm...@gmail.com 09:35 Combobox value Lu 08:12 ...

Sybase PowerBuilder tool readied for Microsoft's .Net
Developers can choose Win32 or newer style .Net development

PowerToTheBuilder - PowerBuilder UI Controls
HOME - COMPONENTS - PB UI DESIGNER - DOWNLOAD\PURCHASE - SUPPORT - FAQ - ABOUT Take Control of your UI with PB Ultimate Suite PowerToTheBuilder.com ...

Beautiful iPad Mini 3 Concept Reimagines Apple’s Tablet With iPhone 6 Design, Gold Color [Images]
The iPhone 6 may be grabbing all of the recent headlines due to its impending announcement, but spare a thought for those who prefer to stay ...

Java Networking - Real's HowTo
Real's HowTo Custom Search Java Language String and Number Applet AWT Swing Environment IO Javascript interaction JDBC Thread Networking JSP ...

Business Intelligence Products - Database Management, Data Warehousing & Mobility Software - Sybase Inc ...
Sybase offers a variety of Business Intelligence (BI) software like products for database management, data warehousing and mining, data integration ...

Resources last updated: 12/20/2015 2:12:18 PM