Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
I'm trying to create column headers in a table visual that would simply read "Adjusted $ YTD (2024)" and "Adjusted $ YTD (2023)", but instead of hardcoding '2024' and '2023', I would like to place the year dynamically. This way when I don't have to change the column headers in 2025, etc. Note: I will always be using 'current year' and 'previous year' data.
Is this simple to do? I have not yet found a post that does this.
Thanks!
Solved! Go to Solution.
Hello @bendsteel6,
Can you please try this:
1. Create Measures for Current Year and Previous Year
AdjustedYTD_CurrentYear =
VAR CurrentYear = YEAR(TODAY())
RETURN
CALCULATE(
SUM('Sales Table'[Amount]),
YEAR('Sales Table'[Date]) = CurrentYear
)
AdjustedYTD_PreviousYear =
VAR PreviousYear = YEAR(TODAY()) - 1
RETURN
CALCULATE(
SUM('Sales Table'[Amount]),
YEAR('Sales Table'[Date]) = PreviousYear
)
2. Add Dynamic Labels to the Measures
AdjustedYTD_CurrentYear_Label =
"Adjusted $ YTD (" & YEAR(TODAY()) & ")"
AdjustedYTD_PreviousYear_Label =
"Adjusted $ YTD (" & YEAR(TODAY()) - 1 & ")"
Hope this helps.
Hi,
Thanks for this! Really appreciate it!
Hello @bendsteel6,
Can you please try this:
1. Create Measures for Current Year and Previous Year
AdjustedYTD_CurrentYear =
VAR CurrentYear = YEAR(TODAY())
RETURN
CALCULATE(
SUM('Sales Table'[Amount]),
YEAR('Sales Table'[Date]) = CurrentYear
)
AdjustedYTD_PreviousYear =
VAR PreviousYear = YEAR(TODAY()) - 1
RETURN
CALCULATE(
SUM('Sales Table'[Amount]),
YEAR('Sales Table'[Date]) = PreviousYear
)
2. Add Dynamic Labels to the Measures
AdjustedYTD_CurrentYear_Label =
"Adjusted $ YTD (" & YEAR(TODAY()) & ")"
AdjustedYTD_PreviousYear_Label =
"Adjusted $ YTD (" & YEAR(TODAY()) - 1 & ")"
Hope this helps.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
75 | |
54 | |
38 | |
31 |
User | Count |
---|---|
99 | |
56 | |
50 | |
42 | |
40 |