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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
mp390988
Helper V
Helper V

Dynamic column headers based on a slicer selection for Fiscal Years stored as text

Hi,

I have two measures, Total Revenue and Previous Period Revenue.
I have the below visuals: a slicer that contains the FY column from my date table and then I have a matrix visual containing the 2 measures.

 

mp390988_2-1748083636152.png

 

What I want to achieve is to display the column headers for the matrix visual depending on the slicer selection.
So for example, based on the slicer selection in the snapshot above, Total Revenue should be replaced with "Revenue for 2024-2025" and Previous Period Revenue should be replaced with "Revenue for 2023-2024".

The FY in my dim date table is a calculated column and is stored as TEXT values as shown below.

 

mp390988_3-1748083712593.png

 

Does anyone know how to do this please?

 

You can download the pbi file here 


Thank You

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @mp390988 

 

Add a column that will make it easy to identify the previous FY based on the current selection.

danextian_0-1748142054694.png

Create a disconnected table with referencing the original dates table and with additional column for the headers.

danextian_1-1748142100425.png

Create this measure

Dynamic Measure = 
VAR _CurrOrder =
    MIN ( 'Dim Date'[FY Order] )
VAR _ValidOrders =
    { _CurrOrder, _CurrOrder + 1 }
VAR _DynamicHeaderOrder =
    MIN ( DynamicHeaders[FY Order] )
RETURN
    CALCULATE (
        [Total Revenue],
        REMOVEFILTERS ( 'Dim Date'[FY], 'Dim Date'[FY Order] ),
        TREATAS (
            INTERSECT (
                _ValidOrders,
                { _DynamicHeaderOrder }
            ),
            'Dim Date'[FY Order]
        )
    )


danextian_2-1748142301034.gif

Please see the attached PBIX.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

10 REPLIES 10
mp390988
Helper V
Helper V

Hi @danextian ,

 

How do you order the headers so that 2025-2026 comes first, then 2024-2025, then 2023-2024 and so forth.

Right now, they are ordered opposite to what I want.

 

mp390988_0-1748279544439.png

 

Thank You

Sort the headers by FY Order

danextian_0-1748316885275.png

danextian_1-1748316916542.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Hi @mp390988 

 

Add a column that will make it easy to identify the previous FY based on the current selection.

danextian_0-1748142054694.png

Create a disconnected table with referencing the original dates table and with additional column for the headers.

danextian_1-1748142100425.png

Create this measure

Dynamic Measure = 
VAR _CurrOrder =
    MIN ( 'Dim Date'[FY Order] )
VAR _ValidOrders =
    { _CurrOrder, _CurrOrder + 1 }
VAR _DynamicHeaderOrder =
    MIN ( DynamicHeaders[FY Order] )
RETURN
    CALCULATE (
        [Total Revenue],
        REMOVEFILTERS ( 'Dim Date'[FY], 'Dim Date'[FY Order] ),
        TREATAS (
            INTERSECT (
                _ValidOrders,
                { _DynamicHeaderOrder }
            ),
            'Dim Date'[FY Order]
        )
    )


danextian_2-1748142301034.gif

Please see the attached PBIX.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian ,

 

Thank you so much for your solution, I am very grateful.

 

I just have a few questions around your solution as follows:

 

1).  I am not sure what use the variable _DynamicHeaderOrder has? It will always evaluate to 1, unless I am mistaken.  In the Intersect function, I see you have used this variable in there but say for example, _CurrOrder = 3 then _ValidOrders =  {3,4} and we know _DynamicHeaderOrder = 1 then the Intersect of _ValidOrders {3,4} and _DynamicHeaderOrder {1} will return empty, right?

mp390988_0-1748191204503.png

 

FY order is simply the ranking of FY with the latest to be always 1. The min rank changes with the slicer selection. Add 1 to that and you get the previous FY.  The attached pbix shows it all. Please review that.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian ,

 

Thank you very much for your solution.

I have reviewed the pbix file and stepped through the measure carefully to understand how it behaves and now I understand.

 

Thank You

mp390988
Helper V
Helper V

I managed to do this by creating a field paramter as follows:

Parameter =
{
    ("Revenue for 2024-2025", NAMEOF('My Measures'[Total Revenue]), 0, "2024-2025"),
    ("Previous Period Revenue 2023-2024", NAMEOF('My Measures'[Previous Period Revenue]),1, "2024-2025"),
    ("Revenue for 2023-2024", NAMEOF('My Measures'[Total Revenue]), 0, "2023-2024"),
    ("Previous Period Revenue 2022-2023", NAMEOF('My Measures'[Previous Period Revenue]),1, "2023-2024"),
    ("Revenue for 2022-2023", NAMEOF('My Measures'[Total Revenue]), 0, "2022-2023"),
    ("Previous Period Revenue 2021-2022", NAMEOF('My Measures'[Previous Period Revenue]),1, "2022-2023"),
    ("Revenue for 2021-2022", NAMEOF('My Measures'[Total Revenue]), 0, "2021-2022"),
    ("Previous Period Revenue 2020-2021", NAMEOF('My Measures'[Previous Period Revenue]),1, "2021-2022"),
    ("Revenue for 2020-2021", NAMEOF('My Measures'[Total Revenue]), 0, "2020-2021"),
    ("Previous Period Revenue 2019-2020", NAMEOF('My Measures'[Previous Period Revenue]),1, "2020-2021")
}
 
but this means a lot of hardcoding of values and requires constant update when new financial years get added.
 
How can I make this dynamic?
PijushRoy
Super User
Super User

Hi @mp390988 
You can also build this in the new card visual. Please find the step in Snap and the attached PBIX file instead of 
Matrix table column header which is not avaialble

PijushRoy_0-1748092098737.png

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Hi,

 

Thank you for your effort but I need to export this data so therefore need it in a matrix visual

PijushRoy
Super User
Super User

Hi @mp390988 
This is possible in a card visual. Please create a measure and use the measure in the Card title.
Please find the attached solution and PBIX file

PijushRoy_1-1748091644271.png

Please keep me posted if that works

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors