Forum Discussion

rajasekaro's avatar
rajasekaro
Helper III
11 months ago
Solved

stock ageing

hi team, i have inventory table , need to calculate Aging  DOCDATE ITEMID QTY PLUSORMINUS BRANCHID LOCID STOCKVALUE 24-11-2024 ITEM001 35 p BRANCH3 LOC2 1247.4 16-09-2024 ITEM0...
  • FarhanJeelani's avatar
    FarhanJeelani
    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.

  • Poojara_D12's avatar
    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 like AgingDays = 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.