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
MITeam
Regular Visitor

Current year (12 months) and Prior Year (12 months) excluding current month

I am struggling with this one - I can do current year and prior for days but for the financials I need months and not include the current month so we dont get hals months at the start and end.

 

I have a table with weekending dates and the month it relates and this table is linked to the main invoice data set.

In the dates table I need to say for example (in Excel):

=IF(AND(V2<EOMONTH(TODAY(),-1)+1,V2>EDATE(EOMONTH(TODAY(),-1)+1,-13)),"Current Year",IF(AND(V2<EDATE(EOMONTH(TODAY(),-1)+1,-12),V2>EDATE(EOMONTH(TODAY(),-1)+1,-25)),"Prior Year","-"))

 

MITeam_0-1678866711588.png

 

My table is called "Month Mapping" and simply has 3 columns:

MITeam_0-1678867050537.png

 

 

Any help truly appreciated

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @MITeam ,

 

 

Here are the steps you can follow:

1. Create calculated column.

Column =
var _today=TODAY()
var _currentend=
EOMONTH(
    _today,-1)
var _currentstart=
EOMONTH(
    _today,-13)
var _prioryear=
EOMONTH(
    _currentstart,-12)
return
IF(
    'Month Mapping'[W/E] >_prioryear&&'Month Mapping'[W/E] <=_currentstart,
    "Prior Year",
    IF(
        'Month Mapping'[W/E]>_currentstart&&'Month Mapping'[W/E]<=_currentend,"Current Year",
       "-"
))

2. Result:

vyangliumsft_0-1679031804248.png

 

Best Regards,

Liu Yang

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @MITeam ,

 

 

Here are the steps you can follow:

1. Create calculated column.

Column =
var _today=TODAY()
var _currentend=
EOMONTH(
    _today,-1)
var _currentstart=
EOMONTH(
    _today,-13)
var _prioryear=
EOMONTH(
    _currentstart,-12)
return
IF(
    'Month Mapping'[W/E] >_prioryear&&'Month Mapping'[W/E] <=_currentstart,
    "Prior Year",
    IF(
        'Month Mapping'[W/E]>_currentstart&&'Month Mapping'[W/E]<=_currentend,"Current Year",
       "-"
))

2. Result:

vyangliumsft_0-1679031804248.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thanks Liu. I realised that the excel formula I put in asking for help worked lol.. People must have read and thought I was a plank:

_CY/PY Full = IF(AND('02. Dates'[_Mmm-yy]<EOMONTH(TODAY(),-1)+1,'02. Dates'[_Mmm-yy]>EDATE(EOMONTH(TODAY(),-1)+1,-13)),"Current Year",IF(AND('02. Dates'[_Mmm-yy]<EDATE(EOMONTH(TODAY(),-1)+1,-12),'02. Dates'[_Mmm-yy]>EDATE(EOMONTH(TODAY(),-1)+1,-25)),"Prior Year","-"))
 
And for prior month /pp month and pppm:
_CY/PY/PPY Month = IF(AND('02. Dates'[_Mmm-yy]<EOMONTH(TODAY(),-1)+1,'02. Dates'[_Mmm-yy]>EDATE(EOMONTH(TODAY(),-1)+1,-2)),[_Mmm-yy],IF(AND('02. Dates'[_Mmm-yy]<EDATE(EOMONTH(TODAY(),-1)+1,-12),'02. Dates'[_Mmm-yy]>EDATE(EOMONTH(TODAY(),-1)+1,-14)),[_Mmm-yy],IF(AND('02. Dates'[_Mmm-yy]<EDATE(EOMONTH(TODAY(),-1)+1,-24),'02. Dates'[_Mmm-yy]>EDATE(EOMONTH(TODAY(),-1)+1,-26)),[_Mmm-yy],0)))
MITeam
Regular Visitor

Anid if a genius can also give me another column to go with this of Last Month and Prior Year Last month so currently it would give Feb 2023 and Feb 2022 I think I would cry with Happiness.

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.