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

Week on week values

Hi all. Fairly new to Power BI.  I have a test set of data with 2 locations and data for 2 weeks.  I would like to get the week on week difference by location, but leave it blank if there is no previous week

This is my data

dannyboy123_0-1707950337715.png

 

This is what I have...

Measur2 =
    VAR cw = CALCULATE(SUM('Table'[success]),FILTER('Table','Table'[week]=MAX('Table'[week])))
    VAR lw = CALCULATE(SUM('Table'[success]),FILTER('Table','Table'[week]=MAX('Table'[week])-1))
    RETURN IF(ISBLANK(lw), BLANK(), cw-lw)
 
This works fine if I don't have week selected in the table..
 
dannyboy123_1-1707950393201.png
But if I add week, the entire table returns as blank.  
 
I want something like this...
 
dannyboy123_2-1707950607020.png

 

Thanks 

2 ACCEPTED SOLUTIONS

@dannyboy123 

output

Daniel29195_0-1707984309910.png

 

Column = 
var w =  'Table'[week]
var depot =  'Table'[depot]

var ds = 
SELECTCOLUMNS(
TOPN(1,
FILTER(
    'Table',
    'Table'[depot] = depot && 'Table'[week] < w
),'Table'[week]
),'Table'[sucess])



var diff =  'Table'[sucess] - ds 

return  IF(ISBLANK(ds) ,BLANK(),diff)

 

let me know if this helps .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

View solution in original post

@dannyboy123 

between ),  and  'Table'[success]   ,  write :  "@success" 

 

the way i wrote it, doesnt work on older power bi version . 

so you need to specify a column name when using selectcolumns . 

 

let me know if this helps .

 

 

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

View solution in original post

6 REPLIES 6
dannyboy123
Frequent Visitor

Hi. Still returns black table if week, depot and measur2 selected

@dannyboy123 

output

Daniel29195_0-1707984309910.png

 

Column = 
var w =  'Table'[week]
var depot =  'Table'[depot]

var ds = 
SELECTCOLUMNS(
TOPN(1,
FILTER(
    'Table',
    'Table'[depot] = depot && 'Table'[week] < w
),'Table'[week]
),'Table'[sucess])



var diff =  'Table'[sucess] - ds 

return  IF(ISBLANK(ds) ,BLANK(),diff)

 

let me know if this helps .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

Seems to work just fine, thank you.

 

It does show an error though...

dannyboy123_0-1708085486234.png

It says paremeter is not correct type? Why is that?

Thanks again

@dannyboy123 

between ),  and  'Table'[success]   ,  write :  "@success" 

 

the way i wrote it, doesnt work on older power bi version . 

so you need to specify a column name when using selectcolumns . 

 

let me know if this helps .

 

 

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

OK, great.  If there was another level of complication, such as if each depot had a sub depot, let's say north and south, how much more difficult would that be?  The success column is a percentage so I wouldn't just want to add up the respective rows and divide, it would need to be based on the total number of parcels eg

dannyboy123_0-1708088914037.png

 

Daniel29195
Super User
Super User

@dannyboy123 

 

 

Measur2 =
    VAR cw = CALCULATE(SUM('Table'[success]),FILTER(all('Table'),'Table'[week]=MAX('Table'[week])))
    VAR lw = CALCULATE(SUM('Table'[success]),FILTER(('Table'),'Table'[week]=MAX('Table'[week])-1))
RETURN IF(ISBLANK(lw), BLANK(), cw-lw)
 
 
let me know if this helps .
 
 
If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠
    

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.