Forum Discussion

tmears's avatar
tmears
Icon for Helper III rankHelper III
9 years ago
Solved

Last month

Hi

 

 

Could some save me loads of time and point in the right direction of a Calcualtion for adding last months and present months sales.  I am using a data table

 SalesCalcualtion
Month 1200200
Month2300500
Month 35001000

 

 

Many thanks 

 

Tim 

 

  • Hi tmears

    That depends ...

     

    When does your calculation start ? In the first month of a year/quarter ... ? Or is it dynamic ?

    If it is dynamic AND you have a calendar table....

    CALCULATE(
       SUM(Table[Sales]),
       FILTER(
            CalendarTable,
            Table[Date] <= MAX (CalendarTable[Date]) &&
            Table[Date] >= MIN (CalendarTable[Date])
            )
       )
       
     You might need to change the "FILTER(CalendarTable .... " to "FILTER(ALL(CalendarTable .... " depending on your needs (context)

    If it's not dynamic ....

    TOTALYTD(SUM(Table[Sales]), Table[Date])

1 Reply

  • Hi tmears

    That depends ...

     

    When does your calculation start ? In the first month of a year/quarter ... ? Or is it dynamic ?

    If it is dynamic AND you have a calendar table....

    CALCULATE(
       SUM(Table[Sales]),
       FILTER(
            CalendarTable,
            Table[Date] <= MAX (CalendarTable[Date]) &&
            Table[Date] >= MIN (CalendarTable[Date])
            )
       )
       
     You might need to change the "FILTER(CalendarTable .... " to "FILTER(ALL(CalendarTable .... " depending on your needs (context)

    If it's not dynamic ....

    TOTALYTD(SUM(Table[Sales]), Table[Date])