cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## Dynamic Title Switcher

Hi all,

I was hoping to get help with a dynamic title of month and year, like so:

This is currently made using the following two formulae:

Title - Selection =
CONCATENATEX(
VALUES(DATE_DIM[MNTH_NAME]),
DATE_DIM[MNTH_NAME],
" & ",
DATE_DIM[MNTH_NAME])
and
Title = [Title - Selection] & " " & SELECTEDVALUE('DATE_DIM'[YR_NBR]) & " - Total Sales Bookings"

The problem arises when I begin to select multiple months like so:

Ideally, the formula would be able to sort the selected value alphabetically when only two months are included, and also use [QTR_NBR] if 3 months in the one quarter were selected.

Any assistance would be greatly appreciated!

Thanks,

James

1 ACCEPTED SOLUTION
Super User

Hi @JLarkin

``````Title - Selection =
CONCATENATEX (
VALUES ( DATE_DIM[MNTH_NAME] ),
DATE_DIM[MNTH_NAME],
" & ",
CALCULATE ( MAX ( DATE_DIM[MNTH_NUMBER] ) ), ASC
)``````

``````Title =
IF (
COUNTROWS ( VALUES ( 'DATE_DIM'[MNTH_NAME] ) ) = 3
&& COUNTROWS ( VALUES ( 'DATE_DIM'[QTR] ) ) = 1,
MAX ( 'DATE_DIM'[QTR] ),
[Title - Selection]
) & " "
& SELECTEDVALUE ( 'DATE_DIM'[YR_NBR] ) & " - Total Sales Bookings"``````

10 REPLIES 10
Super User

Hi @JLarkin

``````Title - Selection =
CONCATENATEX (
VALUES ( DATE_DIM[MNTH_NAME] ),
DATE_DIM[MNTH_NAME],
" & ",
CALCULATE ( MAX ( DATE_DIM[MNTH_NUMBER] ) ), ASC
)``````

``````Title =
IF (
COUNTROWS ( VALUES ( 'DATE_DIM'[MNTH_NAME] ) ) = 3
&& COUNTROWS ( VALUES ( 'DATE_DIM'[QTR] ) ) = 1,
MAX ( 'DATE_DIM'[QTR] ),
[Title - Selection]
) & " "
& SELECTEDVALUE ( 'DATE_DIM'[YR_NBR] ) & " - Total Sales Bookings"``````

Frequent Visitor

Thanks @tamerj1  i've been scratching my head on something similar for a while, this worked perfectly.

How would i go about layering in YTD? For example, if April - August are selected then return "YTD"?

Many thanks,

Matt.

Super User

Hi @mes0012

Frequent Visitor

Hi @tamerj1 ,

So i'm looking to build a dynamic title that breaks down as follows:

- If singular month selected it appears as below

- If two months are selected it appears in a list as below

- If the relevant 3 months are selected for the qtr then return the financial qtr as below

All of the above works perfectly using your original solution.

The bit i'm struggling with is layering in "YTD" if all months are selected. I currently have it structured as below when all months are selected. Instead of a list of the months selected i want it to return "YTD".

Hopefully this makes more sense!

Thanks,

Matt.

Super User

Try to wrap the formula with

IF (

ISFILTERED ( 'Table'[Month] ),

'Original formula',

"YTD"

)

Frequent Visitor

Hi @tamerj1 and @ShahabHoghooghi
Thank you very much to both of you!

Frequent Visitor

Hi,

``````Title - Selection =

VAR __MonthOrder = LOOKUPVALUE(DATE_DIM[MNTH_NUMBER], DATE_DIM[MNTH_NAME], SELECTEDVALUE(DATE_DIM[MNTH_NAME]))

RETURN

CONCATENATEX(
VALUES(DATE_DIM[MNTH_NAME]),
DATE_DIM[MNTH_NAME],
" & ",
__MonthOrder,
ASC)``````

Frequent Visitor

Thank you for your response but this is unfortunately not what I need. The ASC does not take into account the sort column I have on the months, and then does it by alphabetical order. I also require for the title to switch to using the column [QTR_NBR] when 3 months in the same QTR are selected:

For example, selecting the first two months should display "January & February - Total Sales..", and selecting the first three should display "Q1 - Total Sales.."

Many thanks,

James

Frequent Visitor

No, If you have a look at the variable I defined, I used lookup value, then for example it lookup when the month name is March, then it gives you the month number column for that specefic selection, which is 3. It means that, this code will be sorted based on Month Number (numerical) not Month Name and will not be alphabetical.

The second concat measure you created is fine. you just need to change the first one and use month number for sorting instead of month name.

Hope it works for you.

Frequent Visitor

Hi @ShahabHoghooghi
The textbox is using the [Title - Selection] variable you defined, and it still displays as Feb & Mar & Jan, instead of Jan & Feb & Mar.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.