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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
nathanhanser
New Member

Running 12 Month Revenue vs Previous 12 months

Hello Everyone,

 

I have two tables, one that is a clendar with dates/Month fields, and another that has sales info.  Here is an example of the sales table:

 

Sales Date |  Bill Amount
----------------------------------
12/1/2015     |  5
12/11/2015   |  10

1/1/2016       |  5

2/1/2016       |  12
6/1/2016       |  2
7/1/2016       |  4
1/1/2017       |  8
5/1/2017       |  10
6/1/2017       |  15
7/1/2017       |  2

What I need to do is create two measures that show running totals over renning 12 month period.  So if today was 9/30/2017, I would need to show data like this:

 

 

Month/Year   | Sales TY  | Sales LY
----------------------------------------------
10/16            |   0            |   5
11/16            |   0            |   0
12/16            |   0            |   10
1/17              |   8            |   5
2/17              |   0            |   12
3/17              |   0            |   0
4/17              |   0            |   0
5/17              |   10          |   0
6/17              |   15          |   2
7/17              |   2            |   4
8/17              |   0            |   0
9/17              |   0            |   0

I have tired using a calculate with datesbetween like this, but I can't seem to get it working when I use measures to calculate dates rather than hard coding dates:

 

 

Sales TY = CALCULATE(SUM('Bill Amount'),
DATESBETWEEN(
'Calendar'[Date],
"10/1/2016",
"9/30/2016"),
ALL('Calendar'[Date]))

 

 

Any and all helo us much appreicated!

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @nathanhanser

 

In the sample you posted, the expected output isn't a running total, rather it's the sales for that month (not cumulative).

 

If that is the case you can create the following two calculated measures

 

Sales TY = SUM('Table1'[Bill Amount])
Sales LY = CALCULATE(
					SUM('Table1'[Bill Amount]),
					SAMEPERIODLASTYEAR('Dates'[Date])
					)


and then drag them to a table along with a column for Month from your related date/calendar table.

 

 

Sales TY jpg.png

 

Here is a link to download an example PBIX file

 

https://1drv.ms/u/s!AtDlC2rep7a-oEHaSI23CefHfxS6

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @nathanhanser

 

In the sample you posted, the expected output isn't a running total, rather it's the sales for that month (not cumulative).

 

If that is the case you can create the following two calculated measures

 

Sales TY = SUM('Table1'[Bill Amount])
Sales LY = CALCULATE(
					SUM('Table1'[Bill Amount]),
					SAMEPERIODLASTYEAR('Dates'[Date])
					)


and then drag them to a table along with a column for Month from your related date/calendar table.

 

 

Sales TY jpg.png

 

Here is a link to download an example PBIX file

 

https://1drv.ms/u/s!AtDlC2rep7a-oEHaSI23CefHfxS6

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.