Forum Discussion

ashmitp869's avatar
ashmitp869
Icon for Responsive Resident rankResponsive Resident
2 years ago
Solved

How to do date relationship with fact table

Hi All,   I have a Pay Period table which contains data like below     How to do the relationship between fact MpSummaryHours fact table and Pay Period, so that The date field [Pay Period...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi ashmitp869 ,

     

    Thanks DataNinja777  for the quick reply. I have some other thoughts to add:

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data.  

    (2) We can create a measure. 

    Employee Hrs Measure = 
    var _min=CALCULATE(MIN('Pay Period'[Date From]),ALLSELECTED('Pay Period'))
    var _max=CALCULATE(MAX('Pay Period'[Date To]),ALLSELECTED('Pay Period'))
    RETURN CALCULATE(SUM('MpSummaryHours'[Employee Hrs]),FILTER(ALL('MpSummaryHours'),[Pay Period End Date]<=_max && [Pay Period End Date] >= _min))

    (3) Then the result is as follows.

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.