Skip to main content
Announcements
See why Qlik was named a Leader in the 2024 Gartner® Magic Quadrant™ for Data Integration Tools for the ninth year in a row: Get the report
cancel
Showing results for 
Search instead for 
Did you mean: 
shahamel
Creator
Creator

Expression; one year back

Dear QV-users,

I have this expresion. It works. I would like to use a similar expression which uses the same data, but then one year back.

Datum = a date field

Schooljaarlijks_ID = an integer field

Count

(

DISTINCT

{<

Datum = {"=

Datum >=  min({<Schooljaarlijks_ID = {$(=max(Schooljaarlijks_ID))}>}Datum)

and

Datum <=  max({<Schooljaarlijks_ID = {$(=max(Schooljaarlijks_ID))}>}Datum)

        "
},

DateType = {'Deelname'}

>}
DIM_KRD_DEELNEMER.DEELNEMERNUMMER)

I tried expressions like these, but they don't seem to work

Count

(

DISTINCT

{<

Datum = {"=

Datum >=  min({<Schooljaarlijks_ID = {$(=max(Schooljaarlijks_ID)-1)}>}Datum)

and

Datum <=  max({<Schooljaarlijks_ID = {$(=max(Schooljaarlijks_ID)-1)}>}Datum)

        "
},

DateType = {'Deelname'}

>}
DIM_KRD_DEELNEMER.DEELNEMERNUMMER)

or

Count

(

DISTINCT

{<

Datum = {"=

Datum >=  AddYears(min({<Schooljaarlijks_ID = {$(=max(Schooljaarlijks_ID))}>}Datum),-1)

and

Datum <=  AddYears(max({<Schooljaarlijks_ID = {$(=max(Schooljaarlijks_ID))}>}Datum),-1)

        "
},

DateType = {'Deelname'}

>}
DIM_KRD_DEELNEMER.DEELNEMERNUMMER)

or

Count

(

DISTINCT

{<

Datum = {"=

Datum >=  AddMonths(min({<Schooljaarlijks_ID = {$(=max(Schooljaarlijks_ID))}>}Datum),-12)

and

Datum <=  AddMonths(max({<Schooljaarlijks_ID = {$(=max(Schooljaarlijks_ID))}>}Datum),-12)

        "
},

DateType = {'Deelname'}

>}
DIM_KRD_DEELNEMER.DEELNEMERNUMMER)

Please help

1 Reply
Not applicable

Hey Sandeep,

it seems you want to count from a certain point in the past:

to keep things simple try creating a new variable with the AddYear function that expresses this point in time.

Something similar to this:

vMinusYear = num(AddYears(Schooljaarlijks_ID,-1))

Then the count is simple:

=Count(distinct {<Schooljaarlijks_ID={"<$(vMinusYear"}}>} YOURDATA).

Please provide more info for a more detailed answer: