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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
EugeneSledge
New Member

Matching a date range with a sum of values from a related table(s)

I am looking for a solution to create a report table that originally contains start & end dates and it needs to get a summarized aggregation of costs from two related tables pulled in based on the selected interval in the target table. All the tables are connected by a common key. For a better understanding of the solution required - see a visualization of the target table and relationships of the model attached to post. many thanks in advance for any relevant help!

target_table.jpg

relations.jpg

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @EugeneSledge ,

 

First of all let me share some toughts on the setup you have, because my experience on many-to-many relationships with cross filtering is always difficult to control the final result of the calculations even more when you have more than one table in that situation.

This will cause you model to filter from left to right and right to left and you can have a lot of inconsistent results.

 

In this case you can try to add a measure similar to this one:

 

 

Total Cost1 =
CALCULATE (
    SUM ( Cost1[Amount] ),
    FILTER (
        ALLSELECTED ( Cost1[Date] ),
        Cost1[Date] >= SELECTEDVALUE ( Trips[StartDate] )
            && Cost1[Date] <= SELECTEDVALUE ( Trips[EndDate] )
    )
)

 

 

If thids does not work can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
EugeneSledge
New Member

Many thanks Miguel, your suggested measure worked just fine! thanks again! It was a bit unusual and confusing to see double ampersand "&&" in the syntax but it works just the way I wanted! Thanks again!

Hi @EugeneSledge ,

 

The double ampersand is the equivalent to the AND expression if you do the double vertical pipe "||" it's the equivalent of the OR.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi @EugeneSledge ,

 

First of all let me share some toughts on the setup you have, because my experience on many-to-many relationships with cross filtering is always difficult to control the final result of the calculations even more when you have more than one table in that situation.

This will cause you model to filter from left to right and right to left and you can have a lot of inconsistent results.

 

In this case you can try to add a measure similar to this one:

 

 

Total Cost1 =
CALCULATE (
    SUM ( Cost1[Amount] ),
    FILTER (
        ALLSELECTED ( Cost1[Date] ),
        Cost1[Date] >= SELECTEDVALUE ( Trips[StartDate] )
            && Cost1[Date] <= SELECTEDVALUE ( Trips[EndDate] )
    )
)

 

 

If thids does not work can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.