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
Anonymous
Not applicable

Rolling Last Twelve Months Cumulative Bar Graph

I want to create a bar graph that shows the monthly LTM total of sales. So, for example, a bar for July with sales summed from July 2019-August 2018, a Bar of June with sales summed from June 2019 to July 2018, and so on until whatever time period I choose. Say for example the last bar is September 2017, that bar is the sum of sales from September 2017-October 2016. There is nothing with a cumulative monthly LTM bar graph anywhere, please help!!

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

Hello @Anonymous 

This measure assumes you have a Calendar table linked to your data and a measure that sums sales

R12M Sales =
CALCULATE (
    [Sales],
    DATESINPERIOD ( Calendar[Date], MAX ( Calendar[Date] ), -11, MONTH )
)

View solution in original post

It will be a seperte table that you have in the model.  You can use New Table > 

Dates = 
VAR DateRange = CALENDARAUTO()

RETURN
ADDCOLUMNS(
    DateRange,
    "Year",YEAR ( [Date] ),
    "Month", FORMAT ( [Date], "mmmm" ),
    "MonthNum", MONTH ( [Date] ),
    "Month Year", FORMAT ( [Date], "mmm-yyyy"),
    "MonthYearNum", YEAR ( [Date] ) * 100 + MONTH ( [Date] ),
    "Quarter Year", "Q" & FORMAT ( [Date], "q-yyyy" ),
    "QtrYearNum", YEAR ( [Date] ) * 100 + VALUE ( FORMAT ( [Date], "q" ) )
)

Then link the [Date] column of your data to the Dates[Date] column.

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

Hello @Anonymous 

This measure assumes you have a Calendar table linked to your data and a measure that sums sales

R12M Sales =
CALCULATE (
    [Sales],
    DATESINPERIOD ( Calendar[Date], MAX ( Calendar[Date] ), -11, MONTH )
)
Anonymous
Not applicable

Thanks for the quick reply, I have a date linked to each sale. Is the calendar date this date or an independent calendar I bring in to a separate table?

It will be a seperte table that you have in the model.  You can use New Table > 

Dates = 
VAR DateRange = CALENDARAUTO()

RETURN
ADDCOLUMNS(
    DateRange,
    "Year",YEAR ( [Date] ),
    "Month", FORMAT ( [Date], "mmmm" ),
    "MonthNum", MONTH ( [Date] ),
    "Month Year", FORMAT ( [Date], "mmm-yyyy"),
    "MonthYearNum", YEAR ( [Date] ) * 100 + MONTH ( [Date] ),
    "Quarter Year", "Q" & FORMAT ( [Date], "q-yyyy" ),
    "QtrYearNum", YEAR ( [Date] ) * 100 + VALUE ( FORMAT ( [Date], "q" ) )
)

Then link the [Date] column of your data to the Dates[Date] column.

Anonymous
Not applicable

You are a life saver. Going through your process has helped me learn so much about using dates and filtering. Thank you!

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.