This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
I need a measure or column that calculates the difference between the most recent date and the start date of a company's production. For example:
| Branch | Date |
| 4 | 01/01/2025 |
| 4 | 01/05/2025 |
| 5 | 01/02/2025 |
| 5 | 01/10/2025 |
| 4 | 01/20/2025 |
| 6 | 01/03/2025 |
| 5 | 01/15/2025 |
| 6 | 01/05/2025 |
In the above case, I need the difference between the most recent and oldest dates for each branch. For example, for branch 4, the result should be 19.
Solved! Go to Solution.
Hi @jobf - You can create a below measure to find the date diff. For each branch as per given scenerio
Date Difference =
VAR MinDate = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Branch]))
VAR MaxDate = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Branch]))
RETURN
DATEDIFF(MinDate, MaxDate, DAY)
Hope this helps
Proud to be a Super User! | |
Hi @jobf Here is another simple calculated column for your days difference
Days Difference =
VAR MinDate = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Branch]))
VAR MaxDate = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Branch]))
RETURN
(MaxDate - MinDate) * 1.0Results:
Find this helpful? ✔ Give a Kudo • Mark as Solution – help others too!
Hi @jobf - You can create a below measure to find the date diff. For each branch as per given scenerio
Date Difference =
VAR MinDate = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Branch]))
VAR MaxDate = CALCULATE(MAX('Table'[Date]), ALLEXCEPT('Table', 'Table'[Branch]))
RETURN
DATEDIFF(MinDate, MaxDate, DAY)
Hope this helps
Proud to be a Super User! | |
@jobf In your case this should be:
Measure =
VAR __Branch = MAX( 'Table'[Branch] )
VAR __MaxDate = MAXX( FILTER( ALL( 'Table' ), [Branch] = __Branch ), [Date] )
VAR __MinDate = MINX( FILTER( ALL( 'Table' ), [Branch] = __Branch ), [Date] )
VAR __Result = ( __MaxDate - __MinDate ) * 1.
RETURN
__Result
See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column =
VAR __Current = [Value]
VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])
VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
( __Current - __Previous ) * 1.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 36 | |
| 33 | |
| 31 | |
| 24 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 50 | |
| 33 | |
| 24 | |
| 24 |