none
how to find sum of last 4 weeks sales for current year?? RRS feed

  • Question

  • hi all,

    i have a requirement to find sum of last 4 weeks sales for latest year and starting from latest week in data

    suppose i have data for year column as 2016,2017 i should consider latest year that means 2017 and latets week in it ,

    i took DAX measure as:

    sum of 4 Weeks sales = CALCULATE (
    [quantity],
    FILTER (
    ALL ( Calendar ),
    Calendar[Year] = MAX ( Calendar[Year])
    && Calendar[Week] >= MAX (Calendar[Week])-3 )
    )

    but i'm getting blank

    i tried with below formula also:

    Sales 4 Weeks = var yr=CALCULATE(MAX(Calendar[Year]),ALL(Calendar)) 
    var wk=CALCULATE(MAX(Calendar[Week]),ALL(Calendar)) return CALCULATE(SUM(Sales[Quantity]),CALCULATETABLE(Calendar,Calendar[Year]=yr) ,FILTER(Calendar,Calendar[Week]>=MAX(Calendar[Week])-3))

    even though i got blank, how can i acheive sumoflast4weeks sales. Pls help

    thanx in advance..


    lucky

    Friday, November 17, 2017 7:41 AM

Answers

  • By last 4 weeks, do you mean:

    1. The one to six days of the current week
      plus the last 3 weeks.
    2. The last completed 4 weeks.
    3. The last 28 days (the easiest).

    The last year is redundant.

    Since you posted in Power Query,
    the solution will be in "M", not "DAX".

    Friday, November 17, 2017 4:34 PM