The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Dear All,
Thank you in advance to all.
I have month column (Apr,may...mar) and Previous and Current Month Data columns.
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
Solved! Go to Solution.
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"
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.
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] )
)
)
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.
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.
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"
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.
@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