cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

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

Accepted Solutions
Highlighted
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
Highlighted
Super User IV
Super User IV

@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.



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted
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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors