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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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