Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am trying to create a measure that returns the previous year's value, using the following expression:
Solved! Go to Solution.
Hi Mike,
The YEAR column in 'Table' has years 2011 - 2022 formatted as date.
Sample data here:
I've just created a DimDate table using a simple
DimDate = SUMMARIZE('Sheet1 (2)','Sheet1 (2)'[Year])
and have used the Year column in DimDate in the DATEADD expression, this seems to have solved the problem.
However, I am confused as to why using the Year column in DimDate as opposed to Year column in the original Table made a difference - they were both formatted as date so what was the issue?
Hi @timzedel.
For using Time Intelligence functions like DATEADD you need columns with dates. I assume you do not have that right? Can please show the dataset below with sample data?
Best regards
Michael
Hi Mike,
The YEAR column in 'Table' has years 2011 - 2022 formatted as date.
Sample data here:
I've just created a DimDate table using a simple
DimDate = SUMMARIZE('Sheet1 (2)','Sheet1 (2)'[Year])
and have used the Year column in DimDate in the DATEADD expression, this seems to have solved the problem.
However, I am confused as to why using the Year column in DimDate as opposed to Year column in the original Table made a difference - they were both formatted as date so what was the issue?
@timzedel , if you have date table then only then this will work (also you need have date table and use year from date table)
Previous Year Value = CALCULATE([Total Value],
DATEADD('Date'[Date],-1,Day
)
)
Using a separate date/year table
//Only year vs Year, not a level below
This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |