Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dannywallis1994
Frequent Visitor

Rolling sum next 12 months of sales

Hi there, I have the following data and I am looking to create a measure to sum the next 12 months worth of sales. 

 

The calculation I am looking for will be rolling and start from the year month. I have added my desired output below. 

 

Any help would be appreciated.

 

DATA TABLE 
DateRevenue
01/01/2022100
01/01/202295
01/02/202290
01/03/202285
01/04/202280
01/05/202275
01/06/202270
01/07/202265
01/08/202260
01/09/202255
01/10/202250
01/11/202245
01/12/202240
01/01/202335
01/02/202230

 

 

OUTPUT 
MonthRevenue
Jan-22910
Feb-22780

 

Best, 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @dannywallis1994 

 

You can add a Date table to your model and create a relationship from Date table to Sales table on date columns. In Date table, add Month column with formula Month = FORMAT([Date],"mmm-yy"). Put this column and the following measure into a table visual. 

Next 12 month Revenue = 
CALCULATE (
    SUM ( 'Table'[Revenue] ),
    DATESINPERIOD (
        'Date'[Date],
        EOMONTH ( MAX ( 'Date'[Date] ), -1 ) + 1,
        12,
        MONTH
    )
)

vjingzhang_0-1645072084034.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

4 REPLIES 4
Roxanne_pbi_
Frequent Visitor

Hi,
Quite new here so I am not sure if I am allowed to reply to an existing solved topic, but I will try.
Trying to get a similar calculation going, a rolling sum of coming x amount of months, le's say 12.
I followed the above advice and keep getting stuck at this calulation 

Next 12 month FC =

CALCULATE (

    SUM ( 'F1 2023 Totals'[Forecast quantity] ),

    DATESINPERIOD (

        'DimDateQry'[Date],

        EOMONTH ( MAX ( DimDateQry'[Date] ), -1 ) + 1,

        12,

        Month

    )

)

Which gives me this error:
The following syntax error occurred during parsing: Invalid token, Line 6, Offset 35, '[Date] ), -1 ) + 1, 12, Month ))).

Would someone be able to help me please? Happy to offer more context if needed.

 

v-jingzhang
Community Support
Community Support

Hi @dannywallis1994 

 

You can add a Date table to your model and create a relationship from Date table to Sales table on date columns. In Date table, add Month column with formula Month = FORMAT([Date],"mmm-yy"). Put this column and the following measure into a table visual. 

Next 12 month Revenue = 
CALCULATE (
    SUM ( 'Table'[Revenue] ),
    DATESINPERIOD (
        'Date'[Date],
        EOMONTH ( MAX ( 'Date'[Date] ), -1 ) + 1,
        12,
        MONTH
    )
)

vjingzhang_0-1645072084034.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

amitchandak
Super User
Super User

@dannywallis1994 , Create a measure like this with help from date table

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),12,MONTH))

 

or

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MIn('Date'[Date ]),12,MONTH))

Hi @amitchandak 
I tried this solution as well: 

SumRolling 12 = CALCULATE(sum('F1 2023 Totals'[Forecast quantity]),DATESINPERIOD('DimDateQry'[Date],MIN('DimDateQry'[Date]),12,MONTH))
But the result I get is not a rolling sum but the actual forecast value for the month, see pic. Any idea what I'm doing wrong?
Rolling12sum.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.