web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

(0) ShareShare
ReportReport
Posted on by

Hi all,

We have some issues with the transactions in inventtrans back in time. Thus, we want to calculate inventory levels back in time by using INVENTSUM as the main table, and then use the use INVENTTRANS and QTY to calculate back to a given date.

Does anyone have a query that I could use for inspiration?

This is what I am trying, but I get a wrong answer;

SELECT

upper(isum.[DATAAREAID]) as CompanyKey

,isum.[ITEMID] as ItemKey

,sum (

(isum.[POSTEDQTY]+isum.[RECEIVED]-isum.[DEDUCTED]-isum.[PICKED])

+ itns.[QTY]

) as InventorySnapshotOnHandQty

,(

sum (

(isum.[POSTEDQTY]+isum.[RECEIVED]-isum.[DEDUCTED]-isum.[PICKED])

+ itns.[QTY]

)

* invm.[PRICE]

)

as InventorySnapshotOnHandAmountLCY

FROM

[dbo].[AX2009_dbo_INVENTSUM_V] isum

LEFT JOIN

[dbo].[AX2009_dbo_INVENTTRANS_V] itns

on isum.DATAAREAID=itns.DATAAREAID and isum.INVENTDIMID=itns.INVENTDIMID and isum.INVENTDIMID=itns.INVENTDIMID and isum.ITEMID=itns.ITEMID

LEFT JOIN

[dbo].[AX2009_dbo_INVENTDIM_V] idim

on isum.DATAAREAID=idim.DATAAREAID and isum.INVENTDIMID=idim.INVENTDIMID

LEFT JOIN

[dbo].[AX2009_dbo_INVENTTABLEMODULE_V] invm

on isum.DATAAREAID=invm.DATAAREAID and isum.ITEMID=invm.ITEMID and invm.MODULETYPE=0

WHERE

isum.DATAAREAID = 'COMPANYID' AND -- ENTER COMPANY

isum.ITEMID = 'ITEMDIM' and isum.[LASTUPDDATEEXPECTED] <= {ts '2016-11-30 00:00:00.000'} -- ENTER ITEMID AND DATE

GROUP BY

isum.[DATAAREAID]

,isum.[ITEMID]

,invm.[PRICE]

 

When I just calculate the inventory based on inventtrans I get almost the correct number with the following query.

SELECT

upper(itns.[DATAAREAID]) as CompanyKey

,itns.[ITEMID] as ItemKey

,sum(itns.[QTY]) as InventoryTransactionQty

,sum(itns.[COSTAMOUNTPOSTED]+itns.[COSTAMOUNTADJUSTMENT]) as InventoryTransactionAmountLCY

FROM

[dbo].[AX2009_dbo_INVENTTRANS_V] itns

LEFT JOIN

[dbo].[AX2009_dbo_INVENTDIM_V] idim

on itns.DATAAREAID=idim.DATAAREAID and itns.INVENTDIMID=idim.INVENTDIMID

LEFT JOIN

[dbo].[AX2009_dbo_INVENTTABLEMODULE_V] invm

on itns.DATAAREAID=invm.DATAAREAID and itns.ITEMID=invm.ITEMID and invm.MODULETYPE=0

WHERE

itns.DATAAREAID = 'COMPANYKEY' AND -- ENTER LEGAL ENTITY ID

itns.ITEMID = 'ITEMID' and itns.DATEPHYSICAL <= {ts '2016-11-30 00:00:00.000'}

GROUP BY

itns.[DATAAREAID]

,itns.[ITEMID]


 

But as I said, we have some issues with data back in time. Thus it is decided to use INVENTSUM and calculate back in time.

Someone who has I query for inspiration?

 

Bests,

Line, Denmark

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Did you try the Consistency check in a clone of your Production system? That could help with verifying inventory transactions to rebuild InventSum. Basic / Periodic / Consistency check. Since it can run for a long time, try it with smaller filters first in a Test environment to see if you get the desired outcome.

    If you would like to run the processing from code, try this:

    mvpdynamicsax.blogspot.hu/.../recalculate-inventsum.html

  • Line Krogh Profile Picture
    on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Hi Vilmos,

    No it did not. I am actually I BI developer, so i am not a user of AX. I have just been told I should take point of departure in INVENTSUM and the calculated the levels back in time using INVENTTRANS.

    What I want is to calculate ultimo month levels two years back in time :)

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Ok, then we misunderstood each other. Describing the requirements better always helps.

    AX has code to do this already, there is no need to reinvent the wheel in BI/SSRS. It calculates inventory on-hand for a specific item, date and inventory storage dimension:

    https://dynamicsaxgyan.wordpress.com/2011/03/04/find-invent-onhand-by-date-dynamics-ax-x/

  • André Arnaud de Calavon Profile Picture
    299,056 Super User 2025 Season 2 on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Hi Line,

    I do agree with Vilmos. The logic in AX is the single truth. Looking back in history on the InventTrans table is tricky. It all depends on the physical and financial dates used. Also the InventSettlement should then be taken into account. The InventSettlement is storing recalculations on a cost amount in time. Also a nice boobytrap: If the physical date is later than the financial date on the InventTrans, and the financial date is within the date selection and the physical date not. Then what to do...?

    I had build a report in the past to show differences as there were some posting errors. At the end I used the AX logic also used in several reports to get the required data.  

  • Community Member Profile Picture
    on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Use inventvaluecube view. It contains all the info you need and you can back date. You cant backdate reserved quantity as this is a status field in the inventtrans which gets overwritten, unless you include extensive logic from purchline, salesline etc.. Onhand quantity is no problem to backdate.

    If you need more info, feel free to ask. Im quite familiar with the data structure

  • André Arnaud de Calavon Profile Picture
    299,056 Super User 2025 Season 2 on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Hi Martijn,

    Thanks for your insight. Can you also say if this view can back date posted corrections done by inventory closing per item transaction?

  • Community Member Profile Picture
    on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Dear Andre,

    Yes in AX2012 definitely, AX2009 the view doesnt exist but the model stays the same with a few tweaks. I have made the model for both AX2009 and AX2012 and validated them on main account/voucher level at more than 10 customers. It always matched 100%, except on posting then you might encounter slight movements, but totals are 100% match.

    The view revolves around the inventtrans, inventtransposting and inventsettlement. Standard cost transactions can be UNIONed(SQL term) in this view as this isnt part of the standard view.

    If you have additonal questions feel free to ask.

  • Community Member Profile Picture
    on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Posting date*

  • Konrad U Profile Picture
    804 on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    Hello Line,

    As a user of 2009 for a long time we learned to not rely on InventSum for much of anything. We also never got the consistency check to complete.

    Our prior system had an Item Balance file that contained the monthly results that was used for quite a few analyses.

    We created an enhancement that established the beginning inventory in each month and the ending inventory and buckets for each month using InventTrans as its basis. Receipts and issues are summed separately for each month. To update it at month end we run a batch procedure that creates new records for the month in question or updates existing ones. It also traps the value and high and low inventory for each company/site/warehouse. It has been found reliable with results easily exportable to a spreadsheet.

    You may want to consider a similar enhancement.

    Konrad

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: Use INVENTSUM and INVENTTRANS to calculate inventory levels back in time

    The solution for any inventory-related issues is quite simple to be honest. Our warehouse has really high movement for goods, and we wanted to keep track of actual correct inventory levels and if anything tricky is going on. Thus we do continuous counting, it is done as a daily practice for all items touched. This way we know we can rely on inventory on-hand.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans