Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Can we have dynamically changing columns in a Power BI table?

Hi, I have a requirement to dynamically change year columns in a table.

I am looking to create calculated columns with dynamically changing titles. Eg. '2024 Review' for this year, dynamically change to '2025 Review' next year and so on.

Is there a way I can achieve this in Power BI?

6 Replies

  • Hi Anonymous - Create a DAX measure to calculate the current year. This measure will give you that the column titles are always based on the current year.

     

    CurrentYear = YEAR(TODAY())

     

    Now you can create a Calculated column or new column that generates the dynamic column title based on the current year.

     

    DynamicTitle =
    VAR CurrentYear = YEAR(TODAY())
    RETURN
    CONCATENATE(CurrentYear, " Review")

     

    Use this measure Dynamic title in your table chart title (fx) and choose

     

     

     

    It works, Please check.

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!

  • Hi Pragadeesh,

    If I correctly understood, you are trying to create a calculated column for dynamically changing year names.

    For this you can try this calculation based on any of the date/year column of the table as below.

    Add a Calulated Column to your table using the below DAX sample.

    DynamicYear = SWITCH(TRUE(),
                    DimDate[Year] = YEAR(TODAY()), CONCATENATE(DimDate[Year], " Review (This Year)"),
                    DimDate[Year] = YEAR(TODAY())-1, CONCATENATE(DimDate[Year], " Review (Previous Year)"),
                    CONCATENATE(DimDate[Year], " Review"))

    The result will be like this.


    Please accept this a a solution if it helps to resolve your issue. also please give Kudos.

    Thanks in advance 🙂 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rajendraongole1 , AnushaSri ,thank you for your quick reply, I will add more.

    Hi Anonymous ,

    The Table data is shown below:

    Please follow these steps:

    1.Unpivot the following columns.

    2.Use the following DAX expression to create a table

    Table 2 = ADDCOLUMNS({YEAR(TODAY()) & " " & "Delivery",YEAR(TODAY()) - 1 & " " & "Delivery",YEAR(TODAY()) - 2 & " " & "Delivery"},"Year",VALUE(LEFT([Value],4)))

    3.Create a relationship between two tables

    4.Final output

     

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

  • The ADDCOLUMNS pattern works for dynamic column titles. One thing to note: this approach requires updating the DAX expression every time the title format changes  if Marketing decides "Review" should be "Analysis" next quarter, you're back in Desktop.

    For column titles that update automatically based on data (current year, selected period, latest month) without maintaining DAX expressions, Flexa Tables on AppSource handles dynamic column headers natively  column titles reflect the selected periods automatically in the published report