Friday, February 24, 2012

for instance: How do I get the quantity of the last Date for every Location ?

Hello,

How do I get the quantity of the last Date for every Location ?
See example given:

select
[Measures].[Quantity] on columns,
(
nonemptycrossjoin(
[Location].[Location].[Location]
, [Posting Date].[Posting Date]
, 2
)
)
on rows
from
[Logistics]

This query will give me the following result:

Locations

Date

Quantity

Location A

2006-01-01

5

Location A

2006-01-05

3

Location A

2006-01-07

7

Location B

2006-01-01

2

Location B

2006-02-05

3

Location C

2006-01-01

2

Location C

2006-01-01

2

Location C

2006-01-02

3

Location C

2006-01-03

3


This is what I want

Location A

2006-01-07

7

Location B

2006-02-05

3

Location C

2006-01-03

3

Kind regards.

You should take a look at LastNonEmpty aggregation function in AS2005. It does exactly what you need.

|||Let me refine this with another example:

DateLocationHorz. GroupHorz. CodeVert. GroupVert. CodeItemQuantity
2006-1-1A6151I102561
2006-1-2A6151I102562
2006-1-3A6151I102563
2006-1-1B6151I102564
2006-1-3B6151I102565
2006-1-1B6152I102566

The actual supply-result for the year 2006 = 3 + 5 + 6 = 14 (this is correct)
The LastNonEmpty-result in AS2005 = 3 + 5 = 8 (this is not correct, eg. is not sorted by date as you can see but doesn't matter :o)
I actually wanna have the LastNonEmpty grouped by [Date],[Location],[Horz etc],[Vert etc],[Item] ?
How can I force the LastNonEmpty to do that ? Not only Time-related !?
I wanna see the correct supplies in my time-dimension on the level year or month or day :o)
Kind regards.

No comments:

Post a Comment