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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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