11 Replies Latest reply: Oct 24, 2017 5:17 PM by Massimo Grossi

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

• Re: Count data from yesterday and today

May be this

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

• Re: Count data from yesterday and today

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!

• Re: Count data from yesterday and today

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)

• Re: Count data from yesterday and today

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)

• Re: Count data from yesterday and today

Not sure I understand? Did it work?

• Re: Count data from yesterday and today

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)

• Re: Count data from yesterday and today

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....

• Re: Count data from yesterday and today

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)

• Re: Count data from yesterday and today

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!

• Re: Count data from yesterday and today

that code part ,Year=,Week=,Month= from set analysis disregards the dimension selection in Year, Week Month, you should read some nice blog from HIC about set analysis.

Cheers,

Daniel

• Re: Count data from yesterday and today

you can  read this on set analysis

https://community.qlik.com/docs/DOC-4951