maandag, september 03, 2012

The two most recent items (Business Objects)

This is going to be an easy one. Just a tip.

Let's assume, you want to know information for the two most recent pieces of data. Issue is, how do you get those most recent ones.

First, you need a measure -- based on a date.

Year([your_date]) this will get you the year, which is more than unique enough.

to the year, we add 1/12 of our month.


and to that, we add 1/31 of the day.

The thing is, we don't want


to be bigger than


if we divide, we end up with numbers that stay in proportion.

An alternative, and probably an even better way to do this, is to multiply:

(Year([your_date])*10000) +    'that gives us 20120000
(Monthnumberinyear([your_date]) * 100)+   ' that gives us 201212
daynumberinmonth([your_date])  ' that should make 20121224

Interesting, it keeps the date readable. Which is always useful.

So, now we have our measure to base our ranking on -- now it's easy to get the two most recent ones isn't it.



Geen opmerkingen: