Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

DAX Help

Needs to calculate Last 12 months average inventory   Days of Inventory in Hand (DIH) =  Average Inventory / Average daily Net Sales.   Now how to arrive average inventory:   From the selected ...
  • v-deddai1-msft's avatar
    6 years ago

    Hi,

     

    Did you have a calendar table with relationship with your fact table?

     

    You can use the following dax to calculted rolling average inventory for last 12 months:

     

    measure =
    VAR _DATE =
        SELECTEDVALUE ( 'Date'[Date] )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Inventory] ),
            DATESBETWEEN ( 'Date'[Date], DATEADD ( _DATE, -12, MONTH ), _DATE )
        ) / 12

     

    It will be the same for Net Sales. Or you can use quick measure in power bi to calculate rolling average. Please refer to https://www.mssqltips.com/sqlservertip/5635/creating-a-rolling-average-graph-with-power-bi/.

     

    It will be nice if you can show us some sample data by onedrive for business.

     

    Best Regards,

    Dedmon Dai