Forum Discussion
stock ageing
- 11 months ago
Hi rajasekaro ,
For the aging bucket, you can either create separate measures to display in different columns within a table visual, or use the code below to create a single measure and place it in the columns of a matrix visual.
AgingBracket = VAR RefDate = SELECTEDVALUE('Date'[Date], TODAY()) VAR DocDate = MAX('Inventory'[DOCDATE]) -- use the current row/group context VAR AgeDays = DATEDIFF(DocDate, RefDate, DAY)
RETURN SWITCH( TRUE(), AgeDays < 0, "Not due yet", AgeDays <= 30, "0-30", AgeDays <= 60, "31-60", AgeDays <= 90, "61-90", "91+" )
Please mark this post as solution if it helps you. Appreciate Kudos.
- 11 months ago
Hi rajasekaro
To calculate stock aging in Power BI from your inventory table, you first need to establish how long each item has been in stock relative to a dynamic reference date, which should come from a date slicer. Typically, aging is calculated as the difference in days between the document date (
DOCDATE) and either today’s date (TODAY()) or a user-selected date from a slicer. You can create a calculated column likeAgingDays = DATEDIFF(Results[DOCDATE], SELECTEDVALUE('Date'[Date], TODAY()), DAY)to get the number of days in stock for each record. Then, to make the aging analysis meaningful, you usually group these days into aging buckets (for example: 0–30, 31–60, 61–90, 90+), which you can implement with a calculated column or a SWITCH statement. Once this is set up, you can create measures such as total quantity or stock value within each aging bucket. With slicers on Branch, Location, and Date, the report becomes dynamic—users can filter by any branch or location, pick a reference date, and immediately see how stock quantities and values are distributed across the defined aging buckets. This gives a flexible and interactive view of stock aging in your dashboard.
Hi rajasekaro,
Just following up to see if the Response provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.
Best regards,
Prasanna Kumar