cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
admin11
Impactful Individual
Impactful Individual

How to combine 2 expression to display Jul-Sep 21 ?

Hi All

 

Month last -3 =
FORMAT (
DATE ( MAX ( 'Date'[YEAR2] ), MONTH ( TODAY () ) - 3, DAY ( TODAY () ) ),
"mmm-yy")
 
Return :- Jul 21
 
Month last -1 =
FORMAT (
DATE ( MAX ( 'Date'[YEAR2] ), MONTH ( TODAY () ) - 1, DAY ( TODAY () ) ),
"mmm-yy")
 
Return :- Sep 21
 
May i know how to combine above 2 expression into 1 expression , so that it will display Jul-Sep 21 ?
 
Paul
 
2 ACCEPTED SOLUTIONS
mahoneypat
Super User
Super User

Please try this expression instead.

 

MonthRange =
VAR startdate =
    EDATE ( TODAY (), - 3 )
VAR enddate =
    DATE ( MAX ( 'Date'[Year2] )MONTH ( TODAY () ) - 11 )
RETURN
    FORMAT ( startdate"MMM" ) & "-"
        FORMAT ( enddate"MMM yy" )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

You need to change the enddate variable too

 

VAR enddate =
DATE ( MAX ( 'Date'[Year2] ), MONTH ( TODAY () ) - 4, 1 )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Super User
Super User

Please try this expression instead.

 

MonthRange =
VAR startdate =
    EDATE ( TODAY (), - 3 )
VAR enddate =
    DATE ( MAX ( 'Date'[Year2] )MONTH ( TODAY () ) - 11 )
RETURN
    FORMAT ( startdate"MMM" ) & "-"
        FORMAT ( enddate"MMM yy" )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

admin11
Impactful Individual
Impactful Individual

@mahoneypat 

Thank you very much , it work . 

i try to do it for April till June 2021 , it does not work.

Qtr Ptrvious=
VAR startdate =
EDATE ( TODAY (), - 6 )
VAR enddate =
DATE ( MAX ( 'Date'[Year2] ), MONTH ( TODAY () ) - 1, 1 )
RETURN
FORMAT ( startdate, "MMM" ) & "-"
& FORMAT ( enddate, "MMM yy" )

 

may i know where go wrong ?

 

Paul

You need to change the enddate variable too

 

VAR enddate =
DATE ( MAX ( 'Date'[Year2] ), MONTH ( TODAY () ) - 4, 1 )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.