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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Add calculated fields based on date range

I need help!

I have two tables, I want to add four colums to Table 1, based on the Completed Date, where the Completed Date falls between the Start Date and End Date from Table 2.

 

Table 1 - Before

 

Work IDCompleted Date
1126/29/2021
1137/11/2021
1147/13/2021
1157/20/2021

 

Table 2

 

Accounting PeriodFiscal YearCalendar YearPayperiod IDStart DateEnd Date
AP01FY2221146/28/20217/11/2021
AP01FY2221157/12/20217/25/2021
AP02FY2221167/26/20218/8/2021
AP02FY2221178/9/20218/22/2021
AP03FY2221188/23/20219/5/2021
AP03FY2221199/6/20219/19/2021

 

Table 1 - After

 

Work IDWork CompletedAccounting PeriodFiscal YearCalendar YearPayperiod Number
1126/29/2021AP01FY222114
1137/11/2021AP01FY222114
1147/13/2021AP01FY222115
1157/20/2021AP01FY222115

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I will try this! Thank you very much.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

Try these calculated column formulas in Table1

 

CALCULATE(VALUES(Table2[Accounting Period]),FILTER(Table2,Table2[Start Date]<=EARLIER(Table1[Completed Date])&&Table2[End Date]>=EARLIER(Table1[Completed Date])))
CALCULATE(VALUES(Table2[Fiscal Year]),FILTER(Table2,Table2[Start Date]<=EARLIER(Table1[Completed Date])&&Table2[End Date]>=EARLIER(Table1[Completed Date])))
CALCULATE(VALUES(Table2[Calendar Year]),FILTER(Table2,Table2[Start Date]<=EARLIER(Table1[Completed Date])&&Table2[End Date]>=EARLIER(Table1[Completed Date])))
CALCULATE(VALUES(Table2[Payperiod ID]),FILTER(Table2,Table2[Start Date]<=EARLIER(Table1[Completed Date])&&Table2[End Date]>=EARLIER(Table1[Completed Date])))

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

I will try this! Thank you very much.

mussaenda
Super User
Super User

If your table 2 has Work ID column, you can merge them.

Anonymous
Not applicable

Unfortunatley, table 2 does not have the work ID

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.