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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
LLJ1221
Helper I
Helper I

have the difference between 2 dates dynamically

Hello,

 

I don't know if my problem has already been asked on the forum but I haven't found any answers.

 

I have the following table:

Transaction

Operation number

Operation number_1

date operation

1223

080

080

11/02/2023

1223

070

070

05/03/2023

1223

010

010

20/11/2022

1223

0200

0200

01/08/2022

 

The user can choose different operations through two filters (Operation number and Operation number_1) in order to obtain the difference in days between the 2 selected operations.

 

For example if the user filters on operation number = 080 and another filters on operation number_1 = 010, the calculation would be 02/11/2023 - 11/20/2022

 

How can I carry out this calculation using a Dax formula please?

 

Thanks

1 ACCEPTED SOLUTION

Are you able to simply replace the FIRSTDATE() function above with MIN(). That should return the same result, provided there are no blanks.

View solution in original post

3 REPLIES 3
vicky_
Super User
Super User

Please try the following: 

dates selected = 
var OPNo = CALCULATE(FIRSTDATE('Table'[date operation]), ALLEXCEPT('Table', 'Table'[Operation number]))
var OPNo1 = CALCULATE(FIRSTDATE('Table'[date operation]), ALLEXCEPT('Table', 'Table'[Operation number_1]))
return DATEDIFF(OPNo, OPNo1, DAY)

Hi @vicky_ ,

 

Thanks for your feedback.

 

I published to specify sue I susu in Direct Query mode and I know that I had already had problems with the "FirstDate" function because it was not supported in direct query mode

Are you able to simply replace the FIRSTDATE() function above with MIN(). That should return the same result, provided there are no blanks.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.