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
JimJim
Helper V
Helper V

Rolling 13 financial months

Hi Guys,

 

I have attached a pbix file with a date table included. I am trying (and failing) to calculate a column that will let me know if the date is within the previous 13 months (but not including the current month). This sounds easy, but the reason I am struggling is because I need to count financial months and usually dates from one month fall into another financial month, as an example, 25th Oct 2020 - 31st Oct 2020 fall within the financial month of November 2020.

 

On the pbix file, there is a column ExpectedResults, this is the value I am trying to calculate in the IsRolling13M column

 

Please help

 

dates.pbix 

2 ACCEPTED SOLUTIONS
Vera_33
Resident Rockstar
Resident Rockstar

@JimJim 

 

My bad, change the HelpColumn logic to this

HelpColumn = [FinancialYear]*12+[FinancialPeriod]

 

View solution in original post

JimJim
Helper V
Helper V

I managed to work it out, thank you to @Vera_33 for setting me on the right track.

 

It's a bit of a hack but the following code does the job

 

IsRolling13M = 
VAR _month = MONTH(TODAY())
VAR _year = YEAR(TODAY())
RETURN
SWITCH(TRUE(),
    // any month in the same financial year will be within 13 months
    'Time'[FinancialYear] = _year && 'Time'[FinancialPeriod] < _month, TRUE(),
    // any month in the previous year which is greater than or equal to the current month will also be within 13 months
    'Time'[FinancialYear] = _year-1 && 'Time'[FinancialPeriod] >= _month, TRUE(),
    // finally, if the current month is January we need to include December from 2 years previous
    'Time'[FinancialYear] = _year-2 && _month = 1 && 'Time'[FinancialYear] = 12, TRUE(),
    FALSE())

View solution in original post

5 REPLIES 5
JimJim
Helper V
Helper V

I managed to work it out, thank you to @Vera_33 for setting me on the right track.

 

It's a bit of a hack but the following code does the job

 

IsRolling13M = 
VAR _month = MONTH(TODAY())
VAR _year = YEAR(TODAY())
RETURN
SWITCH(TRUE(),
    // any month in the same financial year will be within 13 months
    'Time'[FinancialYear] = _year && 'Time'[FinancialPeriod] < _month, TRUE(),
    // any month in the previous year which is greater than or equal to the current month will also be within 13 months
    'Time'[FinancialYear] = _year-1 && 'Time'[FinancialPeriod] >= _month, TRUE(),
    // finally, if the current month is January we need to include December from 2 years previous
    'Time'[FinancialYear] = _year-2 && _month = 1 && 'Time'[FinancialYear] = 12, TRUE(),
    FALSE())
Vera_33
Resident Rockstar
Resident Rockstar

Hi @JimJim 

 

In your Date table, all the FinancialYear, period...columns are already there? the only one is Rolling13M? Added a helper column, file attached. Let me know if you are looking for something else.

Vera_33_0-1640046708541.png

 

Thank you for your reply, but this doesn't work. November and December 2020 should be included in the Rolling 13 months but as you can see, your solution doesn't include any YEARS before the previous one

 

JimJim_0-1640075263676.png

 

Vera_33
Resident Rockstar
Resident Rockstar

@JimJim 

 

My bad, change the HelpColumn logic to this

HelpColumn = [FinancialYear]*12+[FinancialPeriod]

 

Thank you so much, this is much better than my solution

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.