cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dickkieee Frequent Visitor
Frequent Visitor

DAX Measure for totl SUM between two dates

Hello guys,

 

I'm pretty new to DAX and whant a measure that calculates the value of declaraties.The hard thing to me are the arguments:

 

The measure must calculate only the values where the time between the date of declaration (Fact Table Column enddate) and the start date (Fact Table Colum startdate) is not bigger than 2 years.

 

How can help me out?

 

Kind regards.

 

PS. the datemodel has a fact and a date table

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: DAX Measure for totl SUM between two dates

Hi @Dickkieee,

Based on my test, you could refer to below steps:

Sample data:

1.PNG

Create a calculated column:

Date diff = DATEDIFF('Table1'[Start Date],'Table1'[End Date],DAY)/365

2.PNG

Create a measure and you could see the result:

Sum Value = CALCULATE(SUM('Table1'[Value]),FILTER('Table1','Table1'[Date diff]<=2))

5.PNG

You could also download the pbix file to have a view:

https://www.dropbox.com/s/mn30j112ecqvo1b/DAX%20Measure%20for%20totl%20SUM%20between%20two%20dates.p...

 

Regards,

Daniel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
Community Support Team
Community Support Team

Re: DAX Measure for totl SUM between two dates

Hi @Dickkieee,

Based on my test, you could refer to below steps:

Sample data:

1.PNG

Create a calculated column:

Date diff = DATEDIFF('Table1'[Start Date],'Table1'[End Date],DAY)/365

2.PNG

Create a measure and you could see the result:

Sum Value = CALCULATE(SUM('Table1'[Value]),FILTER('Table1','Table1'[Date diff]<=2))

5.PNG

You could also download the pbix file to have a view:

https://www.dropbox.com/s/mn30j112ecqvo1b/DAX%20Measure%20for%20totl%20SUM%20between%20two%20dates.p...

 

Regards,

Daniel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dickkieee Frequent Visitor
Frequent Visitor

Re: DAX Measure for totl SUM between two dates

Thanks Daniel! It works Smiley HappySmiley Happy