Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
marygrace
Contributor III
Contributor III

Count data from yesterday and today

Hi

I have one question.

I need to count data *Orders from yesterday and today. I tried to do with the bellow sentence

Previous day

Count({<Date = {"$(=Date(Max(Date) - 1,)"}>} OrderNumber)

+

Today

Count({<Date = {"$(=Date(Max(Date)"}>} OrderNumber)

Does not woks

Please help me

1 Solution

Accepted Solutions
maxgro
MVP
MVP

Count(

     {$

          <Date={"$(=Date(max(Date),'DD/MM/YYYY'))"}, Flag={0},Year=,Week=,Month=>

          +

          <Date={"$(=Date(max(Date)-1,'DD/MM/YYYY'))"}, Flag={1},Year=,Week=,Month=>

     }

     distinct OrderNumber)

View solution in original post

11 Replies
sunny_talwar

May be this

Count({<Date = {"$(='>=' & Date(Today() - 1, 'M/D/YYYY') & '<=' & Date(Today(), 'M/D/YYYY'))"}>}OrderNumber)

marygrace
Contributor III
Contributor III
Author

Hi Sunny,

It is works, Now I would like to see the same information, selecting, Year, Month, Week. It is possible to Count Date (today) + PrevDay (yesterday) value with diferents selections.

The measurment Counts all orders released before 16: 40hrs, identified Flag = 1, after 16: 40hrs Flag = 0, So I need to count all orders released today Flag = Flag = 1 Today + Flag = 0 Yesterday) through time.

I hope to be clear.

Thanks!

sunny_talwar

So you don't want to look at Today and Yesterday's value... you want Max selected date and max selected date -1 day value? May be this

Count({<Date = {"$(='>=' & Date(Max(Date) - 1, 'M/D/YYYY') & '<=' & Date(Max(Date), 'M/D/YYYY'))"}, Year, Month, Week>}OrderNumber)

marygrace
Contributor III
Contributor III
Author

Yes, I need to Count Yesterday Flag=0 + Today Flag=1.

this measurment returns the count for today

Count({<Date = {"$(='>=' & Date(Max(Date) - 1, 'DD/MM/YYYY') & '<=' & Date(Max(Date), 'DD/MM/YYYY'))"}, Year, Month, Week>} distinct Numero_OrdenVenta)

sunny_talwar

Not sure I understand? Did it work?

marygrace
Contributor III
Contributor III
Author

No really, it return the count for Orders today, my idea is to have

Count Orders Today Flag = 1 + Count Orders Yesterday Flag =0

Count({<Date = {"$(='>=' & Date(Max(Date) - 1, 'DD/MM/YYYY') & '<=' & Date(Max(Date), 'DD/MM/YYYY'))"}, Year, Month, Week>} distinct Numero_OrdenVenta)

MK9885
Master II
Master II

if(InDay(Date ,today(),0),1,0) as TodayFlag,

if(InDay(Date ,today(),-1),1,0) as YesterdayFlag,

Above 2 statements in your script

and in front end maybe

Count({<TodayFlag={1}>} distinct Numero_OrdenVenta) + Count({<YesterdayFlag={0}>} distinct Numero_OrdenVenta)


Not sure if this would work....

maxgro
MVP
MVP

Count(

     {$

          <Date={"$(=Date(max(Date),'DD/MM/YYYY'))"}, Flag={0},Year=,Week=,Month=>

          +

          <Date={"$(=Date(max(Date)-1,'DD/MM/YYYY'))"}, Flag={1},Year=,Week=,Month=>

     }

     distinct OrderNumber)

marygrace
Contributor III
Contributor III
Author

Hi Massimo,

It´s works!!! when you select specific Date I mean '23/10/2017'.

In case select by week, month, Year, does not works.

I am missing something?

Thank you so much!