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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
mjsystemss
Resolver I
Resolver I

Help Making Column Headers (Dates) Dynamic in PBIX

Hello,

 

I am working on a Power BI Desktop Report Matrix with One Row and 4 Fields in Values Namely
Activity          Lastweek      Weekly_Activity          Today        Percentage(%)                   Total_Amount.

I want Lastweek and Today to show dynamic dates when the report runs. I have tried using card to cover or place on top of the dates but it is not stable when published to Power BI Service.

How can Resolve this.

Thanks

1 ACCEPTED SOLUTION
vojtechsima
Super User
Super User

Hey, @mjsystemss ; you can do this nicely with field parameters with no additional setup (except the field parameters).

 

Result would look like this:

vojtechsima_0-1775230055880.png

First, create the measures you need:

vojtechsima_1-1775230076879.png

Then create a Field Parameter:

vojtechsima_2-1775230101782.pngvojtechsima_3-1775230107245.png

Give it a name and put the measures there (just put anything really, you can modify it later):

vojtechsima_4-1775230150947.png

 

Then go to Data pane; check out the new Field Parameter table and modify if it like this:

vojtechsima_5-1775230193665.pngvojtechsima_6-1775230200909.png

Adjusted order and replace the Text string of the names of Today/LastWeek measures as I have.

Dynamic_Matrix_Headers = {
    (FORMAT(TODAY() - 7, "dd-MM-yyyy"), NAMEOF('Fact_Activity'[Measure_Lastweek]), 0),
    ("Weekly_Activity", NAMEOF('Fact_Activity'[Measure_WeeklyActivity]), 1),
    (FORMAT(TODAY(), "dd-MM-yyyy"), NAMEOF('Fact_Activity'[Measure_Today]), 2),
    ("Percentage(%)", NAMEOF('Fact_Activity'[Measure_Percentage]), 3),
    ("Total_Amount", NAMEOF('Fact_Activity'[Measure_TotalAmount]), 4)
}

 

Then put the Field Parameter's column to your Matrix:

vojtechsima_7-1775230275417.pngvojtechsima_8-1775230280695.png

The name will probably be different, but it doesn't matter.

vojtechsima_9-1775230309855.png

 

Then you'll get this:

vojtechsima_10-1775230324111.png

Attaching PBI, so you can test it yourself.






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

View solution in original post

5 REPLIES 5
v-aatheeque
Community Support
Community Support

Hi @mjsystemss 

Have you had a chance to look through the responses shared earlier? If anything is still unclear, we'll be happy to provide additional support.

 
vojtechsima
Super User
Super User

Hey, @mjsystemss ; you can do this nicely with field parameters with no additional setup (except the field parameters).

 

Result would look like this:

vojtechsima_0-1775230055880.png

First, create the measures you need:

vojtechsima_1-1775230076879.png

Then create a Field Parameter:

vojtechsima_2-1775230101782.pngvojtechsima_3-1775230107245.png

Give it a name and put the measures there (just put anything really, you can modify it later):

vojtechsima_4-1775230150947.png

 

Then go to Data pane; check out the new Field Parameter table and modify if it like this:

vojtechsima_5-1775230193665.pngvojtechsima_6-1775230200909.png

Adjusted order and replace the Text string of the names of Today/LastWeek measures as I have.

Dynamic_Matrix_Headers = {
    (FORMAT(TODAY() - 7, "dd-MM-yyyy"), NAMEOF('Fact_Activity'[Measure_Lastweek]), 0),
    ("Weekly_Activity", NAMEOF('Fact_Activity'[Measure_WeeklyActivity]), 1),
    (FORMAT(TODAY(), "dd-MM-yyyy"), NAMEOF('Fact_Activity'[Measure_Today]), 2),
    ("Percentage(%)", NAMEOF('Fact_Activity'[Measure_Percentage]), 3),
    ("Total_Amount", NAMEOF('Fact_Activity'[Measure_TotalAmount]), 4)
}

 

Then put the Field Parameter's column to your Matrix:

vojtechsima_7-1775230275417.pngvojtechsima_8-1775230280695.png

The name will probably be different, but it doesn't matter.

vojtechsima_9-1775230309855.png

 

Then you'll get this:

vojtechsima_10-1775230324111.png

Attaching PBI, so you can test it yourself.






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.
Natarajan_M
Solution Sage
Solution Sage

Hi @mjsystemss , From your query, I understand that you need dynamic column names in the table. Is my understanding correct?

I tried to recreate the scenario using the sample data , check whetehr the below approach works for you 


Sample Input :

Natarajan_M_1-1775227246624.png


Header table :

Natarajan_M_2-1775227274531.png

 


Sample OP :

Natarajan_M_0-1775227108825.png

MatrixValue = 
SWITCH(
    SELECTEDVALUE(MetricHeaders[MetricKey]),
    "LastWeek",
        CALCULATE(SUM(ActivityData[Amount]),
            ActivityData[Date] = TODAY() - 7),
    "Weekly_Activity",
        CALCULATE(SUM(ActivityData[Amount]),
            ActivityData[Date] >= TODAY() - 7 &&
            ActivityData[Date] <= TODAY()),
    "Today",
        CALCULATE(SUM(ActivityData[Amount]),
            ActivityData[Date] = TODAY()),
    "Percentage",
        DIVIDE(
            CALCULATE(SUM(ActivityData[Amount]), ActivityData[Date] = TODAY()),
            SUM(ActivityData[Amount]), 0),
    "Total_Amount",
        SUM(ActivityData[Amount]),
    BLANK()
)


Header table :

MetricHeaders = 
DATATABLE(
    "SortOrder", INTEGER,
    "MetricKey", STRING,
    {
        {1, "LastWeek"},
        {2, "Weekly_Activity"},
        {3, "Today"},
        {4, "Percentage"},
        {5, "Total_Amount"}
    }
)


Calculated column :

MetricLabel = 
SWITCH(
    MetricHeaders[MetricKey],
    "LastWeek",        "Last Week (" & FORMAT(TODAY()-7, "MMM DD, YYYY") & ")",
    "Weekly_Activity", "Weekly Activity",
    "Today",           "Today (" & FORMAT(TODAY(), "MMM DD, YYYY") & ")",
    "Percentage",      "Percentage (%)",
    "Total_Amount",    "Total Amount",
    MetricHeaders[MetricKey]
)


Pbix :
Today_Weekly.pbix

Thanks 
If you found this helpful, please consider giving it a kudo and marking it as the accepted solution — it goes a long way in helping others facing the same issue.

For more Power BI tips and discussions, let’s connect on LinkedIn:
https://www.linkedin.com/in/natarajan-manivasagan

Cheers!

FBergamaschi
Super User
Super User

Hi @mjsystemss 

can you please show images? That will explain better what you are looking for, which is unclear to me

 

Thanks

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

I want headers encircled to display as dates

mjsystemss_0-1775230286370.png

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.