Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
stvn_003
Contributor III
Contributor III

Counting records before a date

Hello, I wonder what is the correct way to write this expression:

Count( {$<price_ok = {N} , date <= {Today()-7} >} pk_oc )

1 Solution

Accepted Solutions
maxgro
MVP
MVP

maybe this

Count( {$<ocd_precio_ok = {N}, occ_fentr = {"<=$(=Date(Today()-6,'DD/MM/YYYY hh:m:ss tt'))"} >} ocd_cmtrlsap)

1.png

View solution in original post

18 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

this should do it


Count( {$<price_ok = {'N'} , date = {"<=$(=Today()-7)"} >} pk_oc)


here more on set analysis A Primer on Set Analysis

stvn_003
Contributor III
Contributor III
Author

Maybe I'm doing something wrong because when I write this expression shows the number of matches

Count({$<ocd_precio_ok = {N} >} ocd_cmtrlsap)

but when I write this just another expression shows zero

Count( {$<ocd_precio_ok = {'N'} , occ_fentr = {"<=$(=Today()-7)"} >} ocd_cmtrlsap)

maxgro
MVP
MVP

maybe you need to add a date or a date with the same format as occ_fentr

Count( {$<ocd_precio_ok = {N}, occ_fentr = {"<=$(=date(Today()-7))"} >} ocd_cmtrlsap)

stvn_003
Contributor III
Contributor III
Author

Thanks Massimo

But, now two expressions show me the same result

Count( {$<ocd_precio_ok = {N}, occ_fentr = {"<=$(=date(Today()-7,'DD/MM/YYYY))"} >} ocd_cmtrlsap)

sunny_talwar

Do you have data in the last 7 days for ocd_cmtrlsap? If not then both the expressions are correctly showing the same count because there is no data to be counted between 05/07/2015 and 05/13/2015. If you do have data then would you be able to share a sample application to check what is going wrong?

Best,

Sunny

stvn_003
Contributor III
Contributor III
Author

I have this information: ( ocd_cmtrlsap = Nro OC | occ_fentr = Fecha Entrega )

Imagen.png

I want to count how many records there:

Count({$<ocd_precio_ok = {N} >} ocd_cmtrlsap)

and how many records were 7 days ago:

Count( {$<ocd_precio_ok = {N}, occ_fentr = {"<=$(=date(Today()-7,'DD/MM/YYYY))"} >} ocd_cmtrlsap)


But, now two expressions show me the same result, that is to say 6 rows

sunny_talwar

You are missing a single quote after the date format here:

=Count( {$<ocd_precio_ok = {N}, occ_fentr = {"<=$(=Date(Today()-7,'DD/MM/YYYY'))"} >} ocd_cmtrlsap)


May be that will resolve the issue

ramoncova06
Partner - Specialist III
Partner - Specialist III

what happens when you only use Count({$<ocd_precio_ok = {'N'} >} ocd_cmtrlsap)


I am assuming that in your original expression you are actually getting a value because of the fact that you are not using the single quotes to define your constant to filter for ocd_precio_ok 

stvn_003
Contributor III
Contributor III
Author

Now it shows zero =(