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

Difference between two values by Week

Hey guys,

 

I hope all is well!

 

I'm looking for a DAX command that can produce the below results.

 

I have a series of weeks (not dates) that need to show a count up or down and ideally a percentage increase/decrease but I'm strugging to put this into Power BI

 

 

WeekCountResultIncrease/Decrease
Week 455  
Week 466120%
Week 471-5-83.33%
Week 4876600%

 

Is someone able to support with this?

 

Thanks!

 

Steve

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi! 

 

This here might work, using a similar function as the Lag function


https://community.powerbi.com/t5/Desktop/Compute-Lead-and-Lag/td-p/425809

 

All the best,

Pétur

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , refer my blog wow , the rank will help you

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

// That's pretty easy in fact if you have the
// right structure. The table that stores
// weeks must have a column that is a contiguous
// sequence of integers. Let's name the column
// WeekID. Normally, such a column would be hidden
// as it's just a key for the weeks to make them
// distinguishable from each other. This table
// will be connected to some fact table with
// measures.

[Week-by-Week Delta] =
IF(
	// When we calculate the delta,
	// we have to make sure that
	// only one week is visible in
	// the current context.
	HASONEVALUE( Weeks[WeekID] ),
	
	var __currentWeekId = SELECTEDVALUE( Weeks[WeekID] )
	var __currentValue = [CountResult]
	var __priorValue =
		CALCULATE(
			// This is the base measure
			// of which you want to calculate
			// the delta.
			[CountResult],
			Weeks[WeekID] = __currentWeek - 1
		)
	var __delta = __currentValue - __priorValue
	return
		__delta
)

[Increase/Decrease] = DIVIDE( [Week-by-Week Delta], [CountResult] )

 

You might need to adjust the measure to deal with boundary conditions. Simply test it and fix the places where it goes astray.

 

Best

D

Anonymous
Not applicable

Hi! 

 

This here might work, using a similar function as the Lag function


https://community.powerbi.com/t5/Desktop/Compute-Lead-and-Lag/td-p/425809

 

All the best,

Pétur

Anonymous
Not applicable

Worked perfectly !

 

Steve1971_0-1594989819269.png

Thanks all 🙂

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.