Forum Discussion

walnutmercury's avatar
walnutmercury
Frequent Visitor
7 years ago

Previous Value By Region etc

Hi

 

Might be very simple, but I need your help. My Dataset looks like the below, and I need to create the Previous Week Value as well as Totals by Date, by Delta Date.

 

The previous week should Match the Region, Area & Date. The DeltaDate is the snapshot date as I need to track the Amount in $ and % over the snapshot dates.

 

Thanks In advanced.

 

RegionAreaDateDeltaDateAmountPrevious Week
NorthA1Jan-185/10/2018200 
NorthA2Jan-185/10/2018300 
NorthA2Feb-185/10/2018200 
WestA1Feb-185/10/2018100 
WestA2Mar-185/10/2018400 
WestA2Apr-185/10/2018900 
southA1Jan-185/10/201810 
southA2Jan-185/10/20182 
southA2Feb-185/10/201843 
NorthA1Jan-1828/09/201856200
NorthA2Jan-1828/09/2018123300
NorthA2Feb-1828/09/2018452200
WestA1Feb-1828/09/2018400100
WestA2Mar-1828/09/201820400
WestA2Apr-1828/09/201819900
southA1Jan-1828/09/20181510
southA2Jan-1828/09/2018762
southA2Feb-1828/09/20188943
NorthA1Jan-1821/09/201810056
NorthA2Jan-1821/09/2018400123
NorthA2Feb-1821/09/2018900452
WestA1Feb-1821/09/201810400
WestA2Mar-1821/09/2018220
WestA2Apr-1821/09/201840019
southA1Jan-1821/09/20185615
southA2Jan-1821/09/201812376
southA2Feb-1821/09/201840089

2 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi walnutmercury,

       

      You can refer to following calculated column formula to get previous amount:

      previous Amount =
      VAR previous =
          CALCULATE (
              MAX ( Sample[DeltaDate] ),
              FILTER (
                  ALL ( 'Sample' ),
                  [Region] = EARLIER ( [Region] )
                      && [Area] = EARLIER ( [Area] )
                      && [DeltaDate] < EARLIER ( [DeltaDate] )
              )
          )
      RETURN
          MAXX (
              FILTER (
                  ALL ( 'Sample' ),
                  [Region] = EARLIER ( [Region] )
                      && [Area] = EARLIER ( [Area] )
                      && [DeltaDate] = previous
              ),
              [Amount]
          )
      

       

      Regards,

      Xiaoxin Sheng