cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Calculate R12M for EACH MONTH, as one measure

Hi everyone,

 

I'm trying to find a way to calculate R12M sum for each of the months in the table, as one single measure. I'd like it to look more or less like this:

 

Month:January 2019February 2019MarchAprilMayJuneJulyAugustSeptOctNovDecJan 2020Feb 2020March 2020
Value:123451234512345
R12M:           33353739
              (sum March 2019 - Feb 2020)

(sum April 2019-March 2020)

 

I found a way to calculate R12M this year and last year, using the formulas below:

RTM (TY) = CALCULATE([Sales Total Sum]; DATESINPERIOD('Calendar'[Date]; MAX('Calendar'[Date]); -12; MONTH))

RTM (LY) = CALCULATE([Sales Total Sum]; DATEADD(DATESINPERIOD('Calendar'[Date]; MAX('Calendar'[Date]); -12; MONTH); -1; YEAR))

 

However, using this approach I would need to create a separate measure for each month, and it's not what I want.

 

I'd be grateful for any help 🙂

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: Calculate R12M for EACH MONTH, as one measure

@aleksaste your measure RTM (TY)  should work? If not, share what is not working.






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





View solution in original post

5 REPLIES 5
Highlighted
Super User IV
Super User IV

Re: Calculate R12M for EACH MONTH, as one measure

@aleksaste you don't need to create two measure, put year and month from calendar table and one measure would work?

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Highlighted
Frequent Visitor

Re: Calculate R12M for EACH MONTH, as one measure

Could you show me how such a measure would look like?

Highlighted
Super User IV
Super User IV

Re: Calculate R12M for EACH MONTH, as one measure

@aleksaste your measure RTM (TY)  should work? If not, share what is not working.






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





View solution in original post

Highlighted
Community Support
Community Support

Re: Calculate R12M for EACH MONTH, as one measure

Hi,

 

Here is my test table:

6.PNG

Please take following steps:

1)Create a new slicer table by Enter Data:

8.PNG

2)Try this measure:

 

Measure = 
VAR a =
    IF (
        MAX ( 'Table'[Date] ) >= DATE ( 2019, 12, 1 ),
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Date] <= MAX ( 'Table'[Date] )
                    && 'Table'[Date]
                        >= IF (
                            MONTH ( MAX ( 'Table'[Date] ) ) = 12,
                            DATE ( YEAR ( MAX ( 'Table'[Date] ) ) - 1, 1, 1 ),
                            DATE ( YEAR ( MAX ( 'Table'[Date] ) ) - 1, MONTH ( MAX ( 'Table'[Date] ) ) + 1, 1 )
                        )
            )
        )
    )
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Table 2'[Month] ),
        "Value", SUM ( 'Table'[Value] ),
        "R12M", a
    )

 

3)The result shows:

10.PNG

See my attached pbix file.

 

Best Regards,

Giotto

Highlighted
Frequent Visitor

Re: Calculate R12M for EACH MONTH, as one measure

Hi, wasn't aware I can simply plot it on a timeline and it will calculate. For some reason I was convinced that I have to use some kind of variable to select a specific month, becasue I thought it will always take the whole calendar table (without filtering) as a basis. So easy! Thank you.

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors