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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power BI Logic Help

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

DatesDataType
Date 1Date Time
Date 2Date Time
Date 3Date Time
Date 4Date Time
1 ACCEPTED SOLUTION
Anonymous
Not applicable

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:

vyajiewanmsft_0-1718772854843.png

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:

vyajiewanmsft_0-1718773547554.png

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.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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:

vyajiewanmsft_0-1718772854843.png

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:

vyajiewanmsft_0-1718773547554.png

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.

PijushRoy
Super User
Super User

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.




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.