Forum Discussion

ChristianDGreat's avatar
ChristianDGreat
Icon for Resolver I rankResolver I
4 years ago
Solved

Previous Week Sales - Logic (cumulative)

Hello I encounter this request and having a hard time creating a dax formula for this.   so basically I have this table   Date Day of Week Sales 25-Sep Sunday 123 26-Sep Monday 213...
  • amitchandak's avatar
    4 years ago

    ChristianDGreat , As want to display Last week Trend , Make sure there is no date filter, or if there is date filter it should come from independent date table

     

    LWTD Today =
    var _min = TODAY() -WEEKDAY(TODAY(),1) -6 //Sumday week start
    var _max = today() -7
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

     

     

    LWTD Today =

    //Date1 is independent Date table, Date is joined with Table
    var _today = maxx(allselected(Date1),Date1[Date])
    var _min =_today -WEEKDAY(_today ,1) -6 //Sunday week start
    var _max = _today -7
    return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

     

    https://medium.com/chandakamit/cheat-sheet-power-bi-time-intelligence-formulas-using-today-654f26e27304

     

    Need of an Independent Table in Power BI - Exclude: https://youtu.be/lOEW-YUrAbE