September 27, 2010 at 5:26 pm
Hello Experts,
In SSAS , I have designed a fact table named InventoryLookup. I have inserted all item transactions that holds inventory changes to this fact table. So, I can get the correct results from the beginning date and the specified date range in SQL queries.
I run these two SQL queries:
select SUM(Quantity) from InventoryFact
where dateID<'16/08/2010' and warehouseID='1000'
-- returns 20885
select SUM(Quantity) from InventoryFact
where dateID>'08/08/2010' and
dateID<'16/08/2010' and warehouseID='1000'
-- returns -1796
The first query returns the correct inventory value. But SSAS shows the second query's result.
I have attached a screenshot and I am sure that you will understand my problem by looking this screenshot
Any idea?
September 28, 2010 at 7:50 am
What is the hierarchy structure defined on DimDate?
What does '33' refer to in the Hierarchy slice?
September 28, 2010 at 8:05 am
Year --> Month --> WeekOfYear -->DateID
33 is the 33th week of the year.
September 28, 2010 at 8:15 am
Maybe I am missing something, but you are asking for the week 33 SUM from the cube, and that result is the same value as reported by the SQL query (#2).
So, what is the issue?
September 28, 2010 at 10:30 am
The problem is SSAS returns the Equal operator for the datefilter. But it should be <= operator for this date filter.
I can get the correct result by using <= operator.
Is it possible to use <= operator for date filters?
September 28, 2010 at 10:54 am
in SSAS, you are looking at members of a dimension and if you want to use <= operator as in SQL, you have to add up all values from the beginning to the member being pointed to.
See this article for details:
September 28, 2010 at 11:40 am
Thank you very much for your comments.
But, I think in this case I cannot filter my fact table. So, how can show a specific week's inventory values ( I mean the last date for specified week of year) ?
It will always show the latest inventory levels. Right?
September 28, 2010 at 11:48 am
You don't need to filter your fact table - create a calculated measure to add up values from the beginning of the year to the current week and that should give you the inventory level for the week.
September 28, 2010 at 12:36 pm
could you please give me a sample?
September 28, 2010 at 1:13 pm
You have to SUM from the first member to the currentmember at the date level in Time dimension.
Try this:
WITH MEMBER Measures.[Stock Level] AS
SUM([Date].[Hierarchy].[Date].members(0):ClosingPeriod([Date].[Hierarchy].[Date]),
Measures.[Quantity] )
SELECT Measures.[Stock Level] on 0,
[Dim Warehouses MAX].[Store ID] on 1
FROM [Inventory]
WHERE [Date].[Hierarchy].[33]
Do note that this is a simplistic approach and can be refined for performance enhancements.
April 16, 2012 at 9:47 am
I have implemented Richard Tkachuk's inventory solution and it works quite well. Though, I an having an issue that I'm hoping someone can provide an answer. How do I get it too work with a slowly changing dimensions? Richard's solution sum's inventory positions from the first point in time it was entered into the data warehouse. In my situation, the product enters into the warehouse priced at full retail. Invemtory transactions then go in as deltas; +1, -1, +2, etc. As these delta records are entered, I'm fine if the product remains at full retail. When certain products change to a promotional price (promo) , I have inventory records that are deltas associated with a promo indicator 'y' as of the date the product is changed to promo. The previous delta records (and original inventory positon) were a promo indicator of 'n'.
Now of I want to see inventory at any point in time based upon full retail vs. promo, I filter based upon promo indicator. In this case, all my full priced items are fine, but my promo numbers are incorrect. This is because my beginning inventory, which is needed as my starting position, was originally entered as full retail (promo indicator 'n') therefore it does no SUM with my promo items. Essentially in Richard's solution, I end up fltering out my starting inventory positions when I sum up my promo items. Anyone have any ideas how to handle this?
Thanks in advance....
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply