Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
linoyel
Specialist
Specialist

Set analysis - calculate yesterday's sales

Hi,

I'm having trouble in calculate yesterday's sales in set analysis.

The today's sales formula works:

Sum({<DateNum={"$(=Max(DateNum))"}>} Value)

But yesterday's sales formula does not:

Sum({<DateNum={"$(=Max(DateNum-1))"}>} Value)

What's wrong?

33 Replies
sunny_talwar

Didn't you say you have Date and DateNum fields in your app. Not sure where you make selection, but assuming you make selection in Date field, does this work?

Sum({<DateNum={"$(=Max(DateNum)-1)"}, Date>} Value)

linoyel
Specialist
Specialist
Author

No, it still shows 0

sunny_talwar

That is very strange. Would you be able to share a sample where this isn't working?

MK9885
Master II
Master II

I usually try to create flags in Master for easy work...

You can maybe create a flag in Master Calendar

InDay(Date, today(),-1)*-1as PD,

And use

Sum({<PD={1}}>} Value)

linoyel
Specialist
Specialist
Author

Will it be dynamic in UI?

It seems that you always look at today() and compare to it and it's wrong.

I don't need yesterday's date value but the previous date value.

If a user chooses 22/11/2016 so I need to show 21/11/2016's value.

If he chooses 21/11/2016 so I need to show 20/11/2016's value.

MK9885
Master II
Master II

Yes it will give you Yesterday's data not Previous Day data.

MK9885
Master II
Master II

Try this one in Master Calendar

Day(Date-1) as PreviousDay, <<< for Only Day

Date([Date-1,'DD/MM/YYYY') as PreviousDate <<<< Gives you yesterday's date.

and you can use PreviousDate in front end

linoyel
Specialist
Specialist
Author

Attached

sunny_talwar

What is the issue with this expression?

Sum({<DateNum={"$(=Max(DateNum-1))"}, Date>} Amount)

I selected 05/05/2011 and I am seeing both current date and previous date amounts. Are you not seeing this when you open the attached?

Capture.PNG

linoyel
Specialist
Specialist
Author

Thanks, I'll try that