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

Difference between MAX date and another date

Hi folks,

 

I am struggling with a DAX expression to get the difference between the max date in a slicer and the date of the invoices, I mean:

 

I have a table with clients, invoices and dates:

ClientInvoiceDate
client_1INV/000102/05/2018
client_1INV/000203/07/2018
client_1INV/000308/09/2018
client_2INV/000516/06/2018
client_2INV/001220/11/2018

 

And I have a slicer to select my dates, so, I would like to get the difference in days between the MAX(date) in the slicer and each one of my dates, like the following example:

ClientInvoiceDateMAX(date) in selectorDays
client_1INV/000102/05/201815/12/2018227
client_1INV/000203/07/201815/12/2018165
client_1INV/000308/09/201815/12/201898
client_2INV/000516/06/201815/12/2018182
client_2INV/001220/11/201815/12/201825

 

Where MAX(date) in selector comes from the slicer.

 

It would be nice if someone could help me, thanks in advance.

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could create two measures to get it.

max date =
MAXX ( ALLSELECTED ( 'Date'[Date] ), 'Date'[Date] )
Days =
DATEDIFF ( SELECTEDVALUE ( 'Table'[Date] ), [max date], DAY )

Here is the result.

1-1.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

3 REPLIES 3
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could create two measures to get it.

max date =
MAXX ( ALLSELECTED ( 'Date'[Date] ), 'Date'[Date] )
Days =
DATEDIFF ( SELECTEDVALUE ( 'Table'[Date] ), [max date], DAY )

Here is the result.

1-1.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

Hi @v-eachen-msft 

 

could it be possible to do it in a column instead of doing it in a measure?  The reason is that I want to use this calculated value in a selector.

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can create a measure like below.

Days = DATEDIFF( SELECTEDVALUE( 'Table'[Date] ), MAX( dates[Date] ), DAY )

Please see the attached file with the solution.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski


 

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