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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Related Date Time Frame and Location

Is there a way to write a calculation that will find the related time period and return a cost.

 

Table 1. Contract (Lookup Table)

A. Has Contract Number

B. Has Location

 

 

Table 2.  Sales Order.  (Lookup Table)

A. Has Contract Number (Has a primary join from tables 1 to 2 - "one-to-many" relationship)

B. Has Sales Order Date

C. Has Sales Order Number

 

Table 3. Transactions Table (Fact Table)

A. Has Invoice Number (Has a primary join from tables 2 to 3 - "Currently has a secondary "many-to-many" relationship)

B. Has a Transaction Date

B. Has a cost

C. Has a Location

 

Table 4. Locations (Lookup Table)

A. Has list of Locations (Has a primary join from tables 4 to 3 - "one-to-many" relationship &

This also has a secondary join from table 4 to 1 - "one-to-many" relationship)

 

The costs are in Table 3. These costs change periodically and change between location.

 

I wrote a measure:

 

Cost per site =

CALCULATE( [Cost],
TREATAS( VALUES( 'Transaction Table'[Location] ), Contract Table[Location] ) )
 
But I don't think it is calculating correctly.  
 
To increase the complexity, I need to be in the context of the Contract Number.  So the cost depends on two factors.
1st. Location
2nd. Time Period
 
Basically the measure I am trying to create is:
 
Calculate the cost for a contract when the related Location matches the contract, and when the Sales Order matches the related Date-Time Frame.
 
The Time Frame is basically 1 month.
 
So an example would be say I have a contract 00001.  The contract is in Michigan.  I have 3 sales orders.
 
The first Sales order is in Michigan (But this is based off the contract location, not the sales order) and has a date of 2/3/2021.  So I want to take my cost in Michigan and filter it for the month of February 2021.
 
The second Sales order has a date of 3/15/2021, and the third has a date of 4/25/21.
 
Each sales order has a different cost based on month the sales order was written, but the cost is being filtered by the contract location to get the related cost location.  
 
I don't have any sample data prepared, as I thought this might be an easy double filter calculation using related, but now that it is all written out it seems a little more difficult.

 

Any thoughts? Thank you.

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

You may check the topic about How-to-Get-Your-Question-Answered-Quickly .

 

Best Regards,

Jay

TomMartens
Super User
Super User

Hey @Anonymous ,

 

the description of your data model is very precise, thank you for that. Please consider creating a pbix that contains sample data but still reflects your data model, upload the pbix to onedrive or dropbox and share the link. If you are using Excel to create the sample data, share the xlsx as well.

 

At least I need sample data to follow along the description.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors