cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
boa
Helper I
Helper I

Dynamic title with months if it is not a complete year

Hello,

 

I'm working with dynamic titles for the first time and I'm wondering if it is possible to:

1. display only the year in the title if the data of the year is complete

2. display the months or last month with data if the data of the year is not complete

 

I have now a dynamic title that shows the year that is selected. For 2019, 2020 and 2021 this is perfect.

 

boa_0-1668905092883.png

But for 2022 I would like to have 'jan - oct 2022' or '01/01/2022 - 31/10/2020' or something like that that indicates that the year is not complete.

boa_1-1668905221208.png

 

 

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

Hi  @boa ,

I created some data:

vyangliumsft_0-1669021388396.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _select=SELECTEDVALUE('Table'[Date].[Year])
var _mindate=
MINX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))),[Date])
var _maxdate=
MAXX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))),[Date])
return
IF(
    _select=2022,
    _mindate &"-"& _maxdate,
    _select&""&"")

2. Visualizations – Title – Text –fx.

vyangliumsft_1-1669021388397.png

 

vyangliumsft_2-1669021388398.png

3. Result:

Select 2021:

vyangliumsft_3-1669021388399.png

Select 2022:

vyangliumsft_4-1669021388400.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  @boa ,

I created some data:

vyangliumsft_0-1669021388396.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _select=SELECTEDVALUE('Table'[Date].[Year])
var _mindate=
MINX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))),[Date])
var _maxdate=
MAXX(FILTER(ALL('Table'),YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))),[Date])
return
IF(
    _select=2022,
    _mindate &"-"& _maxdate,
    _select&""&"")

2. Visualizations – Title – Text –fx.

vyangliumsft_1-1669021388397.png

 

vyangliumsft_2-1669021388398.png

3. Result:

Select 2021:

vyangliumsft_3-1669021388399.png

Select 2022:

vyangliumsft_4-1669021388400.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

FreemanZ
Community Champion
Community Champion
Jayee
Responsive Resident
Responsive Resident

Hi @boa 

 

Try below measure and adjust the field names according to your dataset

 

Title = if( selected value ( 'table'[year])=year(today()), min(date) && " - " && max(date), max(year))

 

If this post helps, then please consider Accept it as the solution, Appreciate your Kudos!!

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors