Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I have a set of date columns in a table where i need to showcase the timeline progression based on the order of columns.
Suggest me the logic and the related chart for it.
ex: date 2-date 1 = days ,
date 3- date 2 = days
| Dates | DataType |
| Date 1 | Date Time |
| Date 2 | Date Time |
| Date 3 | Date Time |
| Date 4 | Date Time |
Solved! Go to Solution.
Hi @Anonymous ,Hello @PijushRoy ,
Thank you for your prompt reply.
Based on my understanding, you want to calculate difference between dates as days.
Per my test, we can create an index column from 1 in power query for sorting your Date column:
Then create a measure using the following code to meet your requirement:
DateDiff = VAR currentIndex = SELECTEDVALUE('Table'[Index])
VAR currentDate=CALCULATE(SELECTEDVALUE('Table'[Date]),FILTER(ALL('Table'),'Table'[Index]=currentIndex))
VAR preDate=IF(currentIndex=1,CALCULATE(SELECTEDVALUE('Table'[Date]),FILTER(ALL('Table'),'Table'[Index]=1)),
CALCULATE(SELECTEDVALUE('Table'[Date]),FILTER(ALL('Table'),'Table'[Index]=currentIndex-1)))
RETURN
DATEDIFF(preDate,currentDate,DAY)
Result for your reference:
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,Hello @PijushRoy ,
Thank you for your prompt reply.
Based on my understanding, you want to calculate difference between dates as days.
Per my test, we can create an index column from 1 in power query for sorting your Date column:
Then create a measure using the following code to meet your requirement:
DateDiff = VAR currentIndex = SELECTEDVALUE('Table'[Index])
VAR currentDate=CALCULATE(SELECTEDVALUE('Table'[Date]),FILTER(ALL('Table'),'Table'[Index]=currentIndex))
VAR preDate=IF(currentIndex=1,CALCULATE(SELECTEDVALUE('Table'[Date]),FILTER(ALL('Table'),'Table'[Index]=1)),
CALCULATE(SELECTEDVALUE('Table'[Date]),FILTER(ALL('Table'),'Table'[Index]=currentIndex-1)))
RETURN
DATEDIFF(preDate,currentDate,DAY)
Result for your reference:
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
The requirement is not clear to me.
Can you explain more, what is your initial data and what is output you are looking for.
Proud to be a Super User! | |
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 97 | |
| 74 | |
| 50 | |
| 49 | |
| 44 |