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
NadeemAhamed
Helper V
Helper V

Passing Slicer value to column header name

Dear All,

 

Thank you in advance to all. 

 

I have month column (Apr,may...mar) and Previous and Current Month Data columns. 

 

NadeemAhamed_0-1717561666403.png

 

I am trying to pass the slicer values to column header name

if i have selected Apr month in slicer then i want to pass that month name to the column header name such as current month data + Selected month (Apr) and previous month data + Previous month (Mar) from slicer.

 

i have attached the pbix file for your reference. 

 

pbix: https://toyotsu.box.com/s/52e2wnzt2xptn6ql7susxyianj23txqb

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @NadeemAhamed ,

I think the first thing you need to know is that in Power BI Desktop's tables, you can't dynamically change the names of the columns you put in by means like DAX, you can only change its style and static name.

So in your case, I think if you want to implement your needs, maybe you can try using Card Visual. The card is not in the form, but it can be returned in the form you want.

Measure = "Current Month   " & SELECTEDVALUE(Sheet2[Month]) & "   Data"

vyilongmsft_0-1717648657862.png

 

 

 

Best Regards

Yilong Zhou

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

4 REPLIES 4
Anonymous
Not applicable

Hi @NadeemAhamed ,

Firstly I create a new table.

Table = 
VAR _vtable =
    SUMMARIZE (
        ADDCOLUMNS (
            CALENDAR ( "2023-1-1", "2023-12-1" ),
            "_Month", FORMAT ( [Date], "MMM" ),
            "_monthNum", MONTH ( [Date] )
        ),
        [_Month],
        [_monthNum]
    )
RETURN
    EXCEPT (
        _vtable,
        ADDCOLUMNS (
            SELECTCOLUMNS (
                EXCEPT ( SELECTCOLUMNS ( _vtable, [_Month] ), VALUES ( Sheet2[Month] ) ),
                "_mon", [_Month]
            ),
            "MN", MAXX ( FILTER ( _vtable, [_mon] = [_Month] ), [_monthNum] )
        )
    )

vyilongmsft_0-1717643829398.png

Then I create a measure and here is the DAX code.

Measure =
    VAR _currentMonth =
        SELECTEDVALUE ( Sheet2[Month] )
    VAR _currentMonthNum =
        CALCULATE (
            SELECTEDVALUE ( 'Table'[_monthNum] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[_Month] = _currentMonth )
        )
    VAR _PreviousMonthNum =
        CALCULATE (
            MAX ( 'Table'[_monthNum] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[_monthNum] < _currentMonthNum )
        )
    VAR _previousMonth =
        CALCULATE (
            SELECTEDVALUE ( 'Table'[_Month] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[_monthNum] = _PreviousMonthNum )
        )
    VAR _Current =
        MAX ( 'Sheet2'[Current Month Data] ) & SELECTEDVALUE ( Sheet2[Month] )
    VAR _Previous =
        MAX ( 'Sheet2'[Previous Month Data] ) & _previousMonth
    RETURN
        _Current & "-" & _Previous

Finally you will get what you want.

vyilongmsft_1-1717643980433.png

vyilongmsft_2-1717644021418.png

 

 

 

 

Best Regards

Yilong Zhou

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

@Anonymous 

 

Thank you soo much for your valuable time to read and reply my post.

 

actually i want to pass slicer month name in column header not in separate column.

 

NadeemAhamed_0-1717645499644.png

 

Anonymous
Not applicable

Hi @NadeemAhamed ,

I think the first thing you need to know is that in Power BI Desktop's tables, you can't dynamically change the names of the columns you put in by means like DAX, you can only change its style and static name.

So in your case, I think if you want to implement your needs, maybe you can try using Card Visual. The card is not in the form, but it can be returned in the form you want.

Measure = "Current Month   " & SELECTEDVALUE(Sheet2[Month]) & "   Data"

vyilongmsft_0-1717648657862.png

 

 

 

Best Regards

Yilong Zhou

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

amitchandak
Super User
Super User

@NadeemAhamed , check if this workaround can help 

Power BI Time Intelligence- Show month names instead of Current Month Vs Last Month- https://youtu.be/x0DvPn1QeO4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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