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
CourtneyLeah
Frequent Visitor

Calculate sum of the past 3 months

Hi guys,

 

I'm fairly new to Power BI and my DAX knowledge is fairly limited, so bear with me.

 

I have a tabel with the following information:

 

Month Start, Company, # Safety Briefings for month

1/01/2016, Company A, 5

1/01/2016, Company B, 10

1/01/2016, Company C, 15

 

1/02/2016, Company A, 6

1/02/2016, Company B, 4

1/02/2016, Company C, 6

etc

 

What I want to do is calculate the total number of safety briefings completed over the past 3 months.

I have tried creating a new measure using the following:

 

Safety Briefings last 3 months = CALCULATE(sum(Table1[Safety Briefings]), DATESINPERIOD(Table1[Start Date], LASTDATE(Table1[Start Date]), -3, MONTH))

 

However, this only gives me the total for the month, NOT the past 3 months.

 

Any help would be greatly appreciated.

 

Cheers

 

1 ACCEPTED SOLUTION
GilbertQ
Super User
Super User

Hi @CourtneyLeah, it would be best to have a Date Table and link your Month Start to the date table.

 

If that is done you could then create the following calculated measure which should work for you.

 

Safety Briefings last 3 months =
CALCULATE (
    SUM ( Table1[Safety Briefings] ),
    DATEADD ( 'Date'[Calendar Date], -3, MONTH )
)

Formatted using DAX Formatter





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

Proud to be a Super User!







Power BI Blog

View solution in original post

12 REPLIES 12

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.