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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
seankeatingpb
New Member

DAX formula to check validity between start and finish dates and sum up values

Good Day, looking for some assistance if possible with the below:

 

I have a PBI report which includes a slicer for clients, as well as a date range slicer (the date range slicer relates back to a date table). I would like to be able to display the valid Total Agreement Value for that client on my report (card format), depending on the date range selected on the slicer. Is there a way to do this in DAX? I expect it would need to look at dates in-between the Agreement Start Date and Agreement Finish Date, if there are multiple valid agreements it would also need to sum these up.

 

Thanks in advance. 

 

 

 

Sample Data Table below:

 

 

Client      Product           Agreement Start Date      Agreement Finish Date      Active?      Agreement Value      
AHardware01/02/202231/01/2025Yes£32,000
AHardware01/02/201931/01/2022No£32,000
ASoftware01/02/202331/01/2025Yes£9,000
BHardware05/04/202404/04/2025Yes£25,000
BHardware05/04/202304/04/2024No£25,000
BSoftware05/04/202404/04/2026Yes£13,000
CHardware08/10/202307/10/2024No£55,000
CHardware08/10/202407/10/2025Yes£55,000
CSoftware10/03/202309/03/2024No£8,000
DHardware10/03/202109/03/2023No£11,000
DHardware10/03/202309/03/2025Yes£11,000
DSoftware10/03/202309/03/2026Yes£18,000
1 ACCEPTED SOLUTION
Poojara_D12
Super User
Super User

Hello @seankeatingpb 

 

To achieve this in Power BI, we need a DAX measure that will calculate the Total Agreement Value for a selected client within the date range defined by the Agreement Start Date and Agreement Finish Date. This measure will check if an agreement falls within the selected date range, and if so, it will sum up the agreement values for valid agreements.

Here’s a step-by-step approach to create this measure in DAX:

1. Ensure Your Data Model Is Set Up Correctly

Make sure:

  • You have a Date Table in your model that is marked as a Date Table.
  • The Agreement Start Date and Agreement Finish Date columns in your data table are correctly set up to relate to this Date Table.
  • You have a Client slicer and a Date Range slicer (which should be set up using the Date Table).

2. Create a DAX Measure to Calculate the Total Agreement Value

Use the following DAX measure, which will dynamically calculate the total agreement value based on the selected client and date range:

Total Agreement Value = 
VAR SelectedStartDate = MIN('Date'[Date])
VAR SelectedEndDate = MAX('Date'[Date])

RETURN
    CALCULATE(
        SUM('Agreements'[Agreement Value]),
        'Agreements'[Agreement Start Date] <= SelectedEndDate,
        'Agreements'[Agreement Finish Date] >= SelectedStartDate,
        'Agreements'[Active?] = "Yes"
    )

3. Add the Measure to a Card Visual

  • Place this measure in a Card Visual in your Power BI report.
  • When you select a client in the Client slicer and a date range in the Date Range slicer, the card will display the total agreement value for active agreements within the specified date range.

This should now display the Total Agreement Value dynamically based on your selected client and date range.

Let me know if this solution works for your report!

 

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

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

View solution in original post

2 REPLIES 2
Poojara_D12
Super User
Super User

Hello @seankeatingpb 

 

To achieve this in Power BI, we need a DAX measure that will calculate the Total Agreement Value for a selected client within the date range defined by the Agreement Start Date and Agreement Finish Date. This measure will check if an agreement falls within the selected date range, and if so, it will sum up the agreement values for valid agreements.

Here’s a step-by-step approach to create this measure in DAX:

1. Ensure Your Data Model Is Set Up Correctly

Make sure:

  • You have a Date Table in your model that is marked as a Date Table.
  • The Agreement Start Date and Agreement Finish Date columns in your data table are correctly set up to relate to this Date Table.
  • You have a Client slicer and a Date Range slicer (which should be set up using the Date Table).

2. Create a DAX Measure to Calculate the Total Agreement Value

Use the following DAX measure, which will dynamically calculate the total agreement value based on the selected client and date range:

Total Agreement Value = 
VAR SelectedStartDate = MIN('Date'[Date])
VAR SelectedEndDate = MAX('Date'[Date])

RETURN
    CALCULATE(
        SUM('Agreements'[Agreement Value]),
        'Agreements'[Agreement Start Date] <= SelectedEndDate,
        'Agreements'[Agreement Finish Date] >= SelectedStartDate,
        'Agreements'[Active?] = "Yes"
    )

3. Add the Measure to a Card Visual

  • Place this measure in a Card Visual in your Power BI report.
  • When you select a client in the Client slicer and a date range in the Date Range slicer, the card will display the total agreement value for active agreements within the specified date range.

This should now display the Total Agreement Value dynamically based on your selected client and date range.

Let me know if this solution works for your report!

 

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

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Thank you Poojara for your prompt response. My mistake; on my real report, the Active? column is actually in a TRUE/FALSE format rather than Yes/No. Any idea what adjustments i would need to make to the formula to accomodate this? If i change to 'Agreements'[Active?] =  "True" I  receive an error mesage.

Thanks again.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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