cancel
Showing results for
Search instead for
Did you mean:
Member

## Rolling 12 month Sum for completed months

Good morning,

Looking for a rolling 12 month and/or a rolling 365 days of sales, however, if the month is not complete then default to previous months rolling 12 month value.  I've tried several methods on this forum, but nothing seems to be producing the desired result.  Not sure if anyone has any tips to help solve this.  Thank you!!!

Desired result in yellow

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

## Re: Rolling 12 month Sum for completed months

@Jkaelin,

Create the following measures and check if you get expected result.

`last month of last year = CALCULATE([Rolling 12M Sales],FILTER(ALL('Master_Calendar'),'Master_Calendar'[Year]=YEAR(TODAY())-1 && 'Master_Calendar'[MonthOfYear]=12))`
```Expected result = IF(YEAR(TODAY())>MAX('Master_Calendar'[Year])&&TODAY()>EOMONTH(MAX('Master_Calendar'[Date]),0),[Rolling 12M Sales],[last month of last year])
```

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 REPLIES 6
Highlighted
Super User

## Re: Rolling 12 month Sum for completed months

Can you post your formula? I'm guessing it can be fixed with an IF statement and a CALCULATE with a MAX filter but can't know for sure.

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Member

## Re: Rolling 12 month Sum for completed months

@Greg_Deckler

Hey Smoupre! This is one of my formula's.  I've tried a variety of IF, THEN statements to no avail.

Rolling 12M Sales :=
CALCULATE (
[Total Revenue],
DATESBETWEEN (
'Master_Calendar'[Date],
NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( 'Master_Calendar'[Date] ) ) ),
LASTDATE ( 'Master_Calendar'[Date] )
)

This formula was posted by @Vvelarde in another related thread, but it would error out on me.

ValueCalc = if(TODAY()>=EOMONTH(VALUES(Table1[DateRef]);0);EXPRTRUE;EXPRFALSE)

This seems like it should be easy to do but then I can't do it, makes me feel like I have no understanding of Row/Filter context.

Super User

## Re: Rolling 12 month Sum for completed months

So, is the main table you are dealing with 'Master_Calendar' or some other table? And if some other table, what is filtering dates from master_calendar, a relationship?

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Member

## Re: Rolling 12 month Sum for completed months

@Greg_Deckler

The main table is my factSales table.  My main calendar table is 'Master_Calendar'.  Master Calendar is a one-to-many to the factSales table.  Any ideas on a good approach?

Kindly - James

Moderator

## Re: Rolling 12 month Sum for completed months

@Jkaelin,

Create the following measures and check if you get expected result.

`last month of last year = CALCULATE([Rolling 12M Sales],FILTER(ALL('Master_Calendar'),'Master_Calendar'[Year]=YEAR(TODAY())-1 && 'Master_Calendar'[MonthOfYear]=12))`
```Expected result = IF(YEAR(TODAY())>MAX('Master_Calendar'[Year])&&TODAY()>EOMONTH(MAX('Master_Calendar'[Date]),0),[Rolling 12M Sales],[last month of last year])
```

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Member

## Re: Rolling 12 month Sum for completed months

@v-yuezhe-msft

Thank you for your help.  Sorry for delay in responding, I been under the weather.  The measures you created work and appears to do the trick.  Thank you!

## Helpful resources

Announcements

#### Back to School Contest

Engage and empower students with Power BI!

#### Watch Sessions On Demand!

Continue your learning in our online communities.

#### Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

#### PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 262 members 2,814 guests
Recent signins:
Please welcome our newest community members: