Forum Discussion

fahadakbar's avatar
fahadakbar
New Member
8 years ago
Solved

Previous Week Calculations

Hi Guys,

 

I am so stuck here, would really appreciate help

 

I have daily customer account cancellation (called Vol) data. I want to calculate the sum of previous weeks cancelations along with current week cancelations. for the previous week vol calculation I am using the following measure:

 

Vol For Prev Week = CALCULATE(
SUM('Activity Table'[Vol]),
(Filter(ALLSELECTED('Activity Table'),'Activity Table'[Week]=max('Activity Table'[Week])-1)))

 

I then use "Table" visual to show the results (for last 5 weeks). This is how it shows:

 

As you can see, I have additionally put 'District' column, so that i can see cancelations district wise. Here comes the problem.

the above-mentioned measure shows me the total of all the districts for the previous weeks, whereas i want district wise cancellation numbers.

 

How do i get this done

 

Best

Fa 

9 Replies

  • fhill's avatar
    fhill
    Resident Rockstar

    This is a Custom Column (not measure) to display prior week && (and) break up the Districts.

    FOrrest

     

    PW_VOI_2 = CALCULATE(SUM('Activity Table'[VOI]), FILTER(ALLSELECTED('Activity Table'), 'Activity Table'[Week] = (EARLIER('Activity Table'[Week]) - 1) && 'Activity Table'[District] = EARLIER('Activity Table'[District])))

     

    • fahadakbar's avatar
      fahadakbar
      New Member

      Hi Fhill,

       

      many many thanks,

       

      i used this approach earlier, but instead using && i just added another FILTER expression. 

       

      Anyhow, it still seems to have a problem, when i created a custom column using :

       

      Column = calculate (
      sum('Activity Table'[Vol]),
      filter(allselected('Activity Table'),'Activity Table'[Week]= earlier('Activity Table'[Week]) &&
      'Activity Table'[District] = EARLIER('Activity Table'[District])))

       

      the result is apparently showing my the sum of vol for the same week, not previous,

      see below :

       

      what am i doing wrong here?

       

      Thanks

       

      • fhill's avatar
        fhill
        Resident Rockstar

        Make sure you include the 'Minus 1' ( Earlier....  -1 ) part to go back a week.  If this still doesn't work, can you post a sample of your raw data?  It could be a problem that VOI is hard coded for me, but i'm guessing your VOI is already a SUM value of VOI records? 


        FOrrest