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
dliddle
Frequent Visitor

Difference between rows

 

Morning 

 

I have been struggling to get anything that works for calculating the change between two dates for a KPI measure, I want to show the change from the most current report date to the previous report date (e.g Overdue defects would be -2 for last report).  I've tried several ways without success so I've tried creating a table of the values as below and then added a step to work out the previous date to use that to force it, however when ive created the previous date column its only calculated for a few rows and now im wondering if there is some king of formatting issue i've missed that is preventing me doing the calculations ive tried?

dliddle_0-1652261037671.png

Any help would be appreciated

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@dliddle you are using a time intelligence function on a date that is not a proper date column. You can't get the result if it's not in your date column. 
So:
1. Never use time intelligence on columns that are not a date column in a proper date table.
2. If what you want is to subtruct 7 days from a date than write this calculated column instead:
'Tiger Table'[PreviousDate] = 'Tiger Table'[Report Date] - 7
3. If what you want is to get the previous date in that table you can write this calculated column:

'Tiger Table'[PreviousDate] = 
VAR _current_date = 'Tiger Table'[Report Date]
VAR _result = 
	MAXX(
		FILTER(
			'Tiger Table',
			'Tiger Table'[Report Date] < _current_date
		),
		'Tiger Table'[Report Date]
	)
RETURN
	_result

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

3 REPLIES 3
Shishir22
Solution Sage
Solution Sage

Hello @dliddle ,

 

In Power Query, sort the data as per date asc and add index column-

 

Shishir22_0-1652262033152.png

 

After creating Index Column, please try below dax for calculated column-

 

PreviousDate =
VAR _PrevIndex = 'TIGER Table'[Index] - 1
RETURN
    CALCULATE (
        FIRSTNONBLANK ( 'TIGER Table'[Report Date], 0 ),
        FILTER ( ALL ( 'TIGER Table' ), 'TIGER Table'[Index] = _PrevIndex )
    )

 

Shishir22_1-1652262109574.png

 

Please mark it as answer if it resolves your issue. Kudos are also appreciated.

 

 

 

Cheers,
Shishir
SpartaBI
Community Champion
Community Champion

@dliddle you are using a time intelligence function on a date that is not a proper date column. You can't get the result if it's not in your date column. 
So:
1. Never use time intelligence on columns that are not a date column in a proper date table.
2. If what you want is to subtruct 7 days from a date than write this calculated column instead:
'Tiger Table'[PreviousDate] = 'Tiger Table'[Report Date] - 7
3. If what you want is to get the previous date in that table you can write this calculated column:

'Tiger Table'[PreviousDate] = 
VAR _current_date = 'Tiger Table'[Report Date]
VAR _result = 
	MAXX(
		FILTER(
			'Tiger Table',
			'Tiger Table'[Report Date] < _current_date
		),
		'Tiger Table'[Report Date]
	)
RETURN
	_result

 


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

This did it thank you.  This is actually perfect as another table the report dates are not consistently 7 days apart.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors