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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
frankhofmans
Helper IV
Helper IV

Last twelve month total from last day of previous month

Hi all,

 

i have the following question:

 

I want to calculate the number of cases (sicness cases) in the last twelve months, from the last day of the previous month (and then twelve months back). So i need the number of cases between october 1st 2019 till september 30th 2020. In when it's november 4th, i need the number of cases between november 1st 2019 and october 31th 2020.

 

Can someone help me with this question?

 

Case IDStart date
11201-05-2019
11827-07-2019
24330-10-2019
16703-05-2020
77001-11-2019
34502-08-2019
12231-1-2020
45101-07-2020
73230-08-2020

 

So when i want to calculate it from today, i need the cases between october 1st 2019 and september 30th 2020 (6 cases). 

 

Thanks in advance!

 

Regards,

 

Frank

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @frankhofmans ,

 

Two measures to choose from: 

Measure 1 = 
CALCULATE (
    COUNT ( 'Table'[Case Id] ),
    DATESINPERIOD ( 'Date'[Date], EOMONTH (MAX('Date'[Date]), -1 ), -12, MONTH )
)
Measure 2 = 
CALCULATE (
    COUNT ( 'Table'[Case Id] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Start date] <= EOMONTH ( MAX ( 'Table'[Start date] ), -1 )
            && 'Table'[Start date]
                >= EOMONTH ( MAX ( 'Table'[Start date] ), -13 ) + 1
    )
)

measures.JPG

 

 

Best regards

Icey

 

If this post helps,then consider Accepting it as the solution to help other members find it faster.

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @frankhofmans ,

 

Two measures to choose from: 

Measure 1 = 
CALCULATE (
    COUNT ( 'Table'[Case Id] ),
    DATESINPERIOD ( 'Date'[Date], EOMONTH (MAX('Date'[Date]), -1 ), -12, MONTH )
)
Measure 2 = 
CALCULATE (
    COUNT ( 'Table'[Case Id] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Start date] <= EOMONTH ( MAX ( 'Table'[Start date] ), -1 )
            && 'Table'[Start date]
                >= EOMONTH ( MAX ( 'Table'[Start date] ), -13 ) + 1
    )
)

measures.JPG

 

 

Best regards

Icey

 

If this post helps,then consider Accepting it as the solution to help other members find it faster.

amitchandak
Super User
Super User

@frankhofmans ,

 

Try like this with date table

Rolling 12 = CALCULATE(Table(Table[Case Id]),DATESINPERIOD('Date'[Date],eomonth(MAX(Table[Start Date]),-1),-12,MONTH))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.