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

sum only records of today's month

Hi !

i am trying to create an expression that will sum a field but only when the record's date is today's month.

this is what i wrote and it's incorrect:

=sum({<MonthName(date) = {"monthName(Today())"} >} clicks)

for example:

dateclicks
10/1/201310
10/2/20133
10/3/20137
10/4/20138
10/5/20133
9/1/20132
9/2/20138
9/3/20133
9/4/20139
9/5/2013

2

i want the expression to sum only the records from October.

1 Solution

Accepted Solutions
Not applicable
Author

i got it:

Sum({$<month1={$(=month(today()))}>}clicks)

View solution in original post

10 Replies
israrkhan
Specialist II
Specialist II

hi

first create a month field in load script like,

load

Date,

Month(Date) as Month,

Clicks

from abc

then in the expression write.

=sum({<Month = {$(=Month(Today()))}>}Clicks).

Hope it helps.

Not applicable
Author

no it doesnt work.

i attached the qvw

Not applicable
Author

i got it:

Sum({$<month1={$(=month(today()))}>}clicks)

israrkhan
Specialist II
Specialist II

See the attached.

let me know, how it is?

Khan

Not applicable
Author

Please try the below

Data:

Load date, clicks, monthname(date) as Months from abc;

Add a variable in settings/variable overview

vMonth

Set vMonth definition as

=monthname(today())

Use the below code in your calculation

=sum({<Months={"$(=vMonth)"}>} clicks)

Hope this will work for you

Not applicable
Author

another question along the lines of the above ...and if I have to take the value that returns me a field in a table instead of the value of a variable:

= sum ({<Months={"$(=vMonth)"}>} clicks)

For example add the clicks of a prior definition in a table:

Title - MonthsDef

D1 - 1,10,11,12 - Like "1 *"

D2 - 2,3,4,5,6,7,8,9 - Rest

With the following variable work,

September vMonth = (MonthDef like '1* ');

but if I had to use the field definition MonthsDef?????

Not applicable
Author

If I understood you correctly, I will use the below expressions

For Oct, Nov, Dec, Jan

=sum({<Months={"Oct*","Nov*","Dec*","Jan*"}>} clicks)

For the rest

=sum({<Months={"Feb*","Mar*","Apr*","May*","Jun*","Jul*","Aug*","Sep*"}>} clicks)

The reason for using a * is because I have used the Monthname in my previous example. The Monthname function returns the month and year of the date.

Is this what you were looking for?

Not applicable
Author

No, I have not explained well to follow the example and my English is not very good, I mean:

I got it with variables, for example:

Set vGP= (Cuenta like '640*' or like '641*')

 

and then a joint operation of this type if it works:

=sum({<Cuenta = { $(#vGP) }>} Importe)

 

But do not get this:

Titulo

Filtro

  ……

……

GP 

640,641

…..

  …….


For a table of such movements:

Cuenta

Valor 
640000

640001 

2

641000

3
641001 
Not applicable
Author

In this case I will do the following

Add a variable vGP in Variable Overview

Set the definition of vGP as  =' "640*","641*" '

The single quote and double quotes are very important in this case

Then the I use the below expression

sum({<Cuenta={$(vGP)}>} Importe)

Is this what you are looking for?