Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
billuran
Partner - Creator
Partner - Creator

Count If Expression

Hello All, Here is my scenario. I have a file with multiple dates and values. I want to count the frequency of the total values for each date.

DateVolume
1/1/171
1/1/172
1/2/172

so the totals for each date:

DateVolume Total
1/1/173
1/2/172

Now I have another table where it is a list of values 0-1000 which i want to use to create a chart like below:

ValuesCount of values from table above
10
21
31

How do i create this in script and expressions?

Message was edited by: Bill Uran

1 Solution

Accepted Solutions
maxgro
MVP
MVP

let's my try in the script

// test data

s:

load * inline [

Date, Volume

1/1/17, 1

1/1/17, 2

1/2/17, 2

2/2/17, 3

3/2/17, 1

3/2/17, 2

3/2/17, 3

3/2/17, 4

20/2/17, 1

20/2/17, 10

21/2/17, 5

21/2/17, 6

];

// separate table from 0 to 1000

t:

LOAD  

     rowno()-1 as Values

AutoGenerate 1001;

tmp:

LOAD

     Date, sum(Volume) as SumVolume

Resident s

Group By Date;

left join (t)

LOAD

     SumVolume as Values,  count(SumVolume) as CountValues

Resident tmp

group by SumVolume;

DROP Table tmp;

final:

NoConcatenate LOAD

  Values,

  Alt(CountValues,0) as CountValues

Resident t;

DROP Table t;

1.png

View solution in original post

6 Replies
Anil_Babu_Samineni

Here, How data similar to countv (01-01-2017 = 0 / 1 / .... / 1000)

Can you provide Data in dates try a luck

Count({<date = P(countv)>}date)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
billuran
Partner - Creator
Partner - Creator
Author

I edited my question for further detail.

maxgro
MVP
MVP

Try in a chart with

dimension         aggr(sum(Volume), Date) 

expression        count(aggr(sum(Volume), Date))

billuran
Partner - Creator
Partner - Creator
Author

Massimo this is great but it will only show values that exist, i want the dimension values to come from a separate table that goes from 0-1000, with the field called Values.

maxgro
MVP
MVP

let's my try in the script

// test data

s:

load * inline [

Date, Volume

1/1/17, 1

1/1/17, 2

1/2/17, 2

2/2/17, 3

3/2/17, 1

3/2/17, 2

3/2/17, 3

3/2/17, 4

20/2/17, 1

20/2/17, 10

21/2/17, 5

21/2/17, 6

];

// separate table from 0 to 1000

t:

LOAD  

     rowno()-1 as Values

AutoGenerate 1001;

tmp:

LOAD

     Date, sum(Volume) as SumVolume

Resident s

Group By Date;

left join (t)

LOAD

     SumVolume as Values,  count(SumVolume) as CountValues

Resident tmp

group by SumVolume;

DROP Table tmp;

final:

NoConcatenate LOAD

  Values,

  Alt(CountValues,0) as CountValues

Resident t;

DROP Table t;

1.png

billuran
Partner - Creator
Partner - Creator
Author

Worked Perfect, thank you.