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 12 months using year and month column

Hello Community,

            I am trying to create a measure for rolling 12 months.

Rolling.PNG

I don't have day column. So I cannot use DATE functions. Please help me creating the measure.

 

Desired Output: If I select 08/2018, then it should show previous 12 months rolling total.

 

Thanks

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Anonymous

 

Attached the sample file for your reference.

Measure =
IF (
    HASONEVALUE ( 'Calendar'[YearMonth] ),
    CALCULATE (
        SUM ( Data[Sales] ),
        FILTER (
            ALL ( 'Data'[Order] ),
            'Data'[Order]
                >= SELECTEDVALUE ( 'Calendar'[Order_Calendar] ) - 11
                && Data[Order] <= SELECTEDVALUE ( 'Calendar'[Order_Calendar] )
        )
    ),
    CALCULATE ( SUM ( Data[Sales] ) )
)

Regards,

Cherie

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

View solution in original post

5 REPLIES 5
jaswu23
New Member

Hi - I implmented the last year 12 month rolling (usage SAMEPERIODLASTYEAR).

When graphing the data it's displaying Jan to Dec instead of from Jun to Jul (ie the chosen month Jul-19). How can I make it display dynamically based on the chosen end month period showing last.

 

rolling 12 month.jpg

Anonymous
Not applicable

Hi,

 

I am trying to display last 13 months data by clicking on year and month on the slicer. Is there a way we can display the last 12 months data because the table is having a relationship with the dates table.

For example when i click on year 2020 and month Sept it should display up to Sept 2019.

 

Can anyone kindly assist me what DAX should i use?

 

Thanks in advance.

 

Best Regards,

R

v-cherch-msft
Employee
Employee

Hi @Anonymous

 

Attached the sample file for your reference.

Measure =
IF (
    HASONEVALUE ( 'Calendar'[YearMonth] ),
    CALCULATE (
        SUM ( Data[Sales] ),
        FILTER (
            ALL ( 'Data'[Order] ),
            'Data'[Order]
                >= SELECTEDVALUE ( 'Calendar'[Order_Calendar] ) - 11
                && Data[Order] <= SELECTEDVALUE ( 'Calendar'[Order_Calendar] )
        )
    ),
    CALCULATE ( SUM ( Data[Sales] ) )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
LivioLanzo
Solution Sage
Solution Sage

 

Hello @Anonymous

 

As an alternative if you do not want to use a normal Date dimension, you can build a model such as the one below and then use this simple measure:

 

= 
CALCULATE(
    SUM( Sales[Sales] ),
    FILTER(
        ALL( Dates[Month Sequence] ),
        AND(
            Dates[Month Sequence] >= MAX( Dates[Month Sequence] ) - 11,
            Dates[Month Sequence] <= MAX( Dates[Month Sequence] )
        )
    ),
    ALL( Dates )
)

 

Capture.PNGCapture1.PNG

 


 


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


Proud to be a Datanaut!  

dedelman_clng
Community Champion
Community Champion

Assume each value is as of the first of the month, and then you can create a date out of your month and year

 

Dt = DATE([Year], [Month], 1)

 

Attach to a calendar table and you can do time intelligence

 

R12 Measure = CALCULATE([Measure], DATESINPERIOD(DateTab[Date], MAX(DateTab[Date]), -1, YEAR) )

 

Hope this helps

David

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.