Forum Discussion

NBOnecall's avatar
NBOnecall
Helper V
7 years ago
Solved

Average based on date slicer from DImtime table

Hi,   I have been searching this forum and couldn't find anything relating to my question. Hoping someone can help me out.   I have a table called InventorySnapshot and want to create a measure t...
  • NBOnecall's avatar
    NBOnecall
    7 years ago

    I think I got this solved. I don't know if it is the perfect way, but at least from my checking it seems to work.

    True Average = sum('ns InventorySnapshot'[Value])/[Days]
    Days = 
    VAR a =
        FIRSTDATE ( Dimtime[Date] )
    VAR b =
        CALCULATE ( MAX ( Dimtime[Date] ), ALLSELECTED ( Dimtime[Date] ) )
    RETURN
        DATEDIFF ( a, b, DAY )+1

    I would think there would be a better way, but I don't know.