Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
How can we calculate no. of days between two days like
2/12/2020 - 2/20/2020 = 8,
2/20/2020 - 3/24/2020 = 32
like this
Hi @ravi_ch , Please try this:
Step 1: create index column using dax:
Index_column = RANKX(ALL('Tablename'),[Date])
Step 2: using DAX create a new column
PreviousRow = Lookupvalue(tablename[Date], tablename[index_column], tablename[index_column] -1)
Step 3: Create another column for counting the difference
Count = DATEDIFF([Date], [PreviousRow], DAY)
@ravi_ch -> Mark this as a solution & hit the thumbs up, if it works for you. Thanks.
but apply slicer like product mam it won't working.
like for each Product what is difference in days between each sale
Pls try this
Measure =
VAR _last=maxx(FILTER(ALL('Table'),'Table'[Date]<max('Table'[Date])),'Table'[Date])
VAR _DF= DATEDIFF(_last,max('Table'[Date]),DAY)
VAR _last2=maxx(FILTER(ALL('Table'),'Table'[Date]<max('Table'[Date])&&'Table'[Product]=max('Table'[Product])),'Table'[Date])
VAR _DF2=DATEDIFF(_last2,max('Table'[Date]),DAY)
RETURN IF(ISFILTERED('Table'[Product]),_DF2,_DF)
pls see the attachment below.
Proud to be a Super User!
you can create a measure
Measure =
VAR _last=maxx(FILTER(ALL('Table'),'Table'[Date]<max('Table'[Date])),'Table'[Date])
return DATEDIFF(_last,max('Table'[Date]),DAY)
Proud to be a Super User!
@ravi_ch -> You can also do using DAX.
Step 1: Create index column starting with 1 (Transform data -> Index column -> Start from 1)
Step 2: using DAX create a new column
PreviousRow = Lookupvalue(tablename[Date], tablename[index_column], tablename[index_column] -1)
Step 3: Create another column for counting the difference
Count = DATEDIFF([Date], [PreviousRow], DAY)
@ravi_ch -> Mark this as a solution & hit the thumbs up, if it works for you. Thanks.
Hi @ravi_ch ,
You can do this is Power Query.
Step 1- Create an index column.
Step 2 - Add new custom column
paste this code in it:
= try #"Added Index"{[Index]-1} [Date] otherwise null
and then click on OK.
this step is going to take the date present in 2nd row to the first row.
Step 3: Create another column which has your result
Result = DATEDIFF([date], [new column that we created], DAY)
@ravi_ch -> If this works, the please mark it as a solution.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.