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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
mahra-in
Helper II
Helper II

Calculate value between two dates if date falls between two dates in another table

Hi

 

I need your help in calculating the sum of values if the date of that table falls in between two dates from another table

 

Table 1: Spend

 

SupplierCategoryValuePO Date
ABBMotors20006-May-17
SiemensDrives15001-Apr-17
GECable130015-Dec-17
ABBMotors100018-Aug-17
SiemensCable120015-Nov-17

 

Table 2: Contract

 

SupplierCategoryEffective DateEnd Date
ABBMotors1/1/201730-Jun-17
SiemensDrives1/1/20171-Oct-17
GECable1/1/201731-Oct-17

 

Now I want result as 

 

ABB2000
Siemens1500


Since ABB has 2 PO's but only 1 PO falls between the dates from Table 2 similarly Siemens has 2 PO's but only 1 falls between Table 2 dates , GE has only 1 PO and it doesnot falls between the date.

 

Also the remaining supplier TECO doesnot covered under any contract hence not considered

 

Please help

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
ChandeepChhabra
Impactful Individual
Impactful Individual

Hi, You can download the solution excel (powerpivot)

 

A few things that I have done

 

  1. I have created a relationship between Client Name between Spend and Contract Table, assuming that the client name will not be duplicated in the Contract Table
  2. Then I have written the following measure

 

Spend Between Dates = CALCULATE(SUM(Spend[Value]),FILTER(Spend,Spend[PO Date]>=RELATED(Contract[Effective Date])&&Spend[PO Date]<=RELATED(Contract[End Date])))

 

Snapshot of the result

 

Sum between dates.PNG

 

 

View solution in original post

3 REPLIES 3
ChandeepChhabra
Impactful Individual
Impactful Individual

Hi, You can download the solution excel (powerpivot)

 

A few things that I have done

 

  1. I have created a relationship between Client Name between Spend and Contract Table, assuming that the client name will not be duplicated in the Contract Table
  2. Then I have written the following measure

 

Spend Between Dates = CALCULATE(SUM(Spend[Value]),FILTER(Spend,Spend[PO Date]>=RELATED(Contract[Effective Date])&&Spend[PO Date]<=RELATED(Contract[End Date])))

 

Snapshot of the result

 

Sum between dates.PNG

 

 

Anonymous
Not applicable

Hi! Could you tell me please what should I do if between theese two tables is another one? This table keep all information about client account. Relationships is created by "account id".

Anushka
New Member

Hi,

 

You need to have a relationship beween the two tables to achieve this. (Better if you have numeric column rather than creating relationship between supplier columns.)

 

Then you can create a calculated column in Spend table , something like below.

 

ValueSpent= IF([PO Date] > RELATED(Contract[EffectiveDate].[Date]) && [Date] < RELATED(Contract[EndDate]), Spend[Value] , 0) 

 

Finally, get the sum of the newly created column. 

 

Hope this helps

 

 

Thanks

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.