Forum Discussion

dannyboy123's avatar
dannyboy123
Frequent Visitor
2 years ago
Solved

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 previ...
  • Daniel29195's avatar
    Daniel29195
    2 years ago

    dannyboy123 

    output

     

    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! 🤠

  • Daniel29195's avatar
    Daniel29195
    2 years ago

    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! 🤠