cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Memorable Member

## How to make my card display 2019 when i click year = 2019 ?

Hi All

Now i have below expression working fine , it will display April 2021.

Month Last =
FORMAT(DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY())),"mmm-yyyy")

May i know how to change the above expression , so that when i click on year=2018 , the card will display 2018 ?
1 ACCEPTED SOLUTION
Community Support

You could  change YEAR(TODAY()) to the value of the slicer，Here can use MAX() ,as follows:

``````_Month last =
FORMAT (
DATE ( MAX ( 'Date'[YEAR2] ), MONTH ( TODAY () ) - 1, DAY ( TODAY () ) ),
"mmm-yyyy")
``````

The final output is shown below:

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 REPLIES 3
Community Support

You could  change YEAR(TODAY()) to the value of the slicer，Here can use MAX() ,as follows:

``````_Month last =
FORMAT (
DATE ( MAX ( 'Date'[YEAR2] ), MONTH ( TODAY () ) - 1, DAY ( TODAY () ) ),
"mmm-yyyy")
``````

The final output is shown below:

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

Try

``````Month Last =

FORMAT(
DATE(
YEAR( SELECTEDVALUE(DATE[YEAR])),
MONTH(TODAY())-1,
DAY(TODAY()))
,
"mmm-yyyy"
)``````
Did I answer your question? Mark my post as a solution! and hit thumbs up
Memorable Member

i use your expression , when i select year = 2017 , but it display 1905

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors