Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
safrik
Frequent Visitor

Dynamic Measure Title Based on Slicer Selection

Dear all,

Is it possble to dynamically change the "title" of a measure according to slicer selection?

I have a simple data structure with tha sales quantity of various product over longer period of time:
structure.png
and a date table.

 

I have a two measures:

Sales Current_Month = SUM(Sales[Amount])
Sales Prev_Month = CALCULATE([Sales Current_Month], PREVIOUSMONTH('Date'[Period]))

 

As a result I have a slicer and matrix as follows:

current.png

But I would like to dynamically change the "title" according to slicer selection to make it much easier for end user to understand on which period they are looking, as follows:

expected.png

If I would select on slicer period 2020.03, measures title in first column would change to "Sales 2020.02" and second to "Sales 2020.03". Is it possible to do it?

Thank you

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

Hi, @safrik 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

Calendar(a calculated table):

Calendar = 
ADDCOLUMNS(
    CALENDARAUTO(),
    "YearMonth",
    YEAR([Date])*100+MONTH([Date])
)

 

YM(a calculated table):

YM = DISTINCT('Calendar'[YearMonth])

 

Relationship:

b2.png

 

You may create a measure like below.

Result = 
var yearmonth = MAX(YM[YearMonth])
var lastym = 
    CALCULATE(
        MAX('Calendar'[YearMonth]),
        FILTER(
            ALL('Calendar'),
            [YearMonth]<yearmonth
        )
    )
return
IF(
        MAX('Calendar'[YearMonth]) in {yearmonth,lastym},
        SUM('Table'[Amount])
)

 

Finally you need to use 'YearMonth' column from 'YM' table to filter the result and set the 'Result' as not blank.

b3.png

 

Best Regards

Allan

 

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

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @safrik 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

Calendar(a calculated table):

Calendar = 
ADDCOLUMNS(
    CALENDARAUTO(),
    "YearMonth",
    YEAR([Date])*100+MONTH([Date])
)

 

YM(a calculated table):

YM = DISTINCT('Calendar'[YearMonth])

 

Relationship:

b2.png

 

You may create a measure like below.

Result = 
var yearmonth = MAX(YM[YearMonth])
var lastym = 
    CALCULATE(
        MAX('Calendar'[YearMonth]),
        FILTER(
            ALL('Calendar'),
            [YearMonth]<yearmonth
        )
    )
return
IF(
        MAX('Calendar'[YearMonth]) in {yearmonth,lastym},
        SUM('Table'[Amount])
)

 

Finally you need to use 'YearMonth' column from 'YM' table to filter the result and set the 'Result' as not blank.

b3.png

 

Best Regards

Allan

 

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

 

Anonymous
Not applicable

Good day,
And if I want only one column of my matrix to change, how would the metric formula look? I need that only when choosing a year.month I change the title of the column, and not like in the example of the formula that selects a year.month and changes the title of the matrix to the selected one and changes the previous one to the selected one

Thank you

Anonymous
Not applicable

In case there are any doubts, I want that when I select the filter for Accounting period 1, it appears in the title of the first column "FY17", and when I select the filter for Accounting period 2, obtain in the second column the title "FY20 ", as seen in the image:

Snap 2021-03-26 at 09.28.02.png

Thank you very much.

rajulshah
Resident Rockstar
Resident Rockstar

Hello @safrik 

 

For now, you cannot do that dynamically for Column Headers.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors