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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
Community Champion
Community Champion

@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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors