Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

SUMIF


How would I SUM IF in the script? 

For example I want to SUM Category if type = 'Start', if issues = 'None' and if  Number1 = 20

Sum(IF(Category = 'Start' and(Issues= 'None') and(Number1 = '20'),1,0) as [TestCount],

1 Solution

Accepted Solutions
sunny_talwar

May be this:

Table:

LOAD Category,

          Issues,

          Number1,

          OtherFields

FROM source

Join(Table)

LOAD Count(Category) as [TestCount]

Resident Table

Where Category = 'Start' and Issues = 'None' and Number1 = 20;

View solution in original post

5 Replies
sinanozdemir
Specialist III
Specialist III

Hi,

How about this one?

Sum(IF(Category = 'Start' and Issues= 'None'  and Number1 = '20' ,1,0)) as [TestCount],

rubenmarin

Hi, in script you are loading values row by row, to use Sum() in script you'll need to group your data using 'Group by', so there are more than one value to sum.

In your script maybe you don't need that, just mark each record as '1' or '0' and do the sum in the chart.

Script:

IF(Category = 'Start' and Issues= 'None' and Number1 = '20',1,0) as [TestCount],


Design (chart):

Sum([TestCount])

sunny_talwar

May be this:

Table:

LOAD Category,

          Issues,

          Number1,

          OtherFields

FROM source

Join(Table)

LOAD Count(Category) as [TestCount]

Resident Table

Where Category = 'Start' and Issues = 'None' and Number1 = 20;

Mark_Little
Luminary
Luminary

HI,

The below will give flag which can be be counted in the front end

IF(Category = 'Start' and Issues= 'None'  and Number1 = '20',1,0) as [TestCount]

Or below

Load

    KEyField,

    IF(Category = 'Start' and Issues= 'None'  and Number1 = '20',SUM(1)) as [TestCount]

Resident 'Your table'

Group by 'the field you want counting by'  //I.e. Product category.


Mark

sinanozdemir
Specialist III
Specialist III

Didn't pay attention you said in the script. sunindia‌'s answer should work in this case.