Forum Discussion

ImaDAXman's avatar
ImaDAXman
Frequent Visitor
9 years ago
Solved

Aggregate $Amt from fact table based on dynamic date range from a different fact table

I've been struggling with this one for a while.  I know the solution is going to be fairly easy and I'll be kicking myself for having spent such a long time blanking on this.  Here is what I'm trying...
  • dedelman_clng's avatar
    9 years ago

    Is FactInventory to DimInventory 1:1 or Many:1 ?

     

    If 1:1, you can create a relationship between FactServHist and FactInventory, then your measure should be something like

     

    TotalRecon = sumx(
      FILTER(FactServHistory,
        FactServHistory[Type]="INTERNAL" && 
        FactServHistory[Date] >= RELATED(FactInventory[Recon Start]) &&
        FactServHistory[Date] <= RELATED(FactInventory[Recon Finish])),
      FactServHistory[$AMT]
    )

     

    If DimInventory : FactInventory is not 1:1, (and therefore FactServHistory : FactInventory = many : many) you'll probably need additional bridge tables to be able to find the right dates in the FactInventory table.

     

    Hope this helps

    David