Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
ashmitp869
Responsive Resident
Responsive Resident

How to do date relationship with fact table

Hi All,

 

I have a Pay Period table which contains data like below

ashmitp869_0-1714977028427.png

 

 

How to do the relationship between fact MpSummaryHours fact table and Pay Period, so that

The date field [Pay Period End Date] can be use to check i,e if Year 2024 and Month 02 is selected.

The [Pay Period End Date] should do a checking from [Date From] to [Date To]

i.e date 31/01/2024 to 27/02/2024

 

Any suggestion ?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.  

vtangjiemsft_0-1715153915615.pngvtangjiemsft_1-1715153927739.png

(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.

vtangjiemsft_2-1715153962875.png

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. 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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.  

vtangjiemsft_0-1715153915615.pngvtangjiemsft_1-1715153927739.png

(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.

vtangjiemsft_2-1715153962875.png

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. 

DataNinja777
Super User
Super User

Hi @ashmitp869 

When there are multiple date fields in your fact tables (such as above, where there are "Date From" and "Date To"), the correct data model is to have a Calendar table and your fact table with multiple date fields as disconnected tables.  By having them as disconnected tables, you are free to do any time dimension analysis of your fact tables.  This is akin to headcount analysis where employee number is dependent on both the start date and the end date in relation to any particualr point in time in the calendar table.  The article below discusses this technique in relation to multiple date fields in employee tables.  

https://p3adaptive.com/finding-the-magic-part-2-on-the-way-to-data-happiness/

Best regards,

Hi ,

Sorry may be I explain it wrong.

My report needs to be filter from Year and Month from Pay Periods (marked in Yellow) and the Employees Hrs needs to be calculated depending on Year selections(2024) and Month (02) 

 

Report filter selection made by user

ashmitp869_2-1714986907402.png

 

The it should do the SUM(Employee Hrs) for  [Pay Period End Date] >='31/01/2024' and [Pay Period End Date] <='27/02/2024'

 

which is defined in [Pay Period] table ( see screenshot 2)

ashmitp869_0-1714985752306.png

see screenshot 2

 

 

ashmitp869_1-1714986064386.png

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.