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
v-danhe-msft Super Contributor
Super Contributor

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.

View solution in original post

3 REPLIES 3
v-danhe-msft Super Contributor
Super Contributor

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.

View solution in original post

Dickkieee Frequent Visitor
Frequent Visitor

Re: DAX Measure for totl SUM between two dates

Thanks Daniel! It works :):)

Highlighted
Fuzel Frequent Visitor
Frequent Visitor

Re: DAX Measure for totl SUM between two dates

Hey @v-danhe-msft 

 

How would the structure of DAX change if I say that my end date is in a differen table?

I have to sum the demand for a part during the timeline of RTS_date + 90. For example a part X has an RTS 01/01/2000 then I have to calculate the total demand for this part using period from demand table which is RTS date + 90 days. SO basically sum the demand from demand table where the period is before 03/01/2000(assumed 30 days each month)

 

I have attached the table pic for two different tables.

Demand Table:

date_dax1.JPGdate_dax.JPG

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 162 members 1,781 guests
Please welcome our newest community members: