Forum Discussion
StaceyGriffeth
5 years agoHelper II
Dynamic table column name
Is there a way to have the column name in a table visual dynamically update? For example, I have a Trailing Twelve Month where it lists the current month and previous 11 month income statements. Th...
Greg_Deckler
5 years agoCommunity Champion
StaceyGriffeth In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick/ba-p/279563
If you can share data, can be more specific.
StaceyGriffeth
5 years agoHelper II
Greg_Deckler Here is the table:
The farthest right column, Cur, is the current month being reported (in this case June). -1 means current month less 1 (May), and so on. I have the following measures which set the current reporting month (updated monthly) and year (updated annually):
ReportMonth = 6
ReportYear = 2020
PriorYear = [ReportYear]-1
I am trying to automate this as much as possible, so I do not want to have to manually change the table column titles every time the month is advanced. For example, this month, -1 is May, but next month -1 will be June. I have measures which set what month and year is -1, -2, etc based on ReportMonth and ReportYear:
TTMReportMonth-1 = SWITCH([ReportMonth], 1, 12, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11)
ReportShortMonthCurrent-1 = SWITCH([ReportMonth],2, "JAN", 3, "FEB", 4, "MAR", 5, "APR", 6, "MAY", 7, "JUN", 8, "JUL", 9, "AUG", 10, "SEP", 11, "OCT", 12, "NOV", 1, "DEC")
TTMReportYear-1 = SWITCH([ReportMonth], 1, [PriorYear], 2, [ReportYear], 3, [ReportYear], 4, [ReportYear], 5, [ReportYear], 6, [ReportYear], 7, [ReportYear], 8, [ReportYear], 9, [ReportYear], 10, [ReportYear], 11, [ReportYear], 12, [ReportYear])
The month and year for -1, -2. etc are combined in the following:
TTM ReportMonthyear-1 = [ReportShortMonthCurrent-1]&" "&[TTMReportYear-1]
And can be displayed in a card and placed above the table column as the column title:
However, when data is refreshed with July as the current month, the column widths will change and the cards as titles will no longer line up with the table columns.