- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Calculation with date table with previous date not working
I have a Date Table dimension (created in DAX) and a fact Sales table where there is a connection with Dates[Date] and Sales[Date].
I need to get the max Year on the date filter and show the previous year net value.
Probably there are other specific functions to do these but I need the calculation to be done in DAX.
If the Max Year of the date slicer is 2024, when I use the following calculation it works:
Net Value = Calculate(
SUM(Sales[NetValue]),
Dates[Year] = 2023
)
BUT if I do this it doesn't work:
Net Value =
VAR previousYear = MAX(Dates[Year]) -1
RETURN
Calculate(
SUM(Sales[NetValue]),
Dates[Year] = previousYear
)
Can anyone help me?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

pls try this
Net Value =
VAR previousYear = MAX(Dates[Year]) -1
RETURN
Calculate(
SUM(Sales[NetValue]),FILTER(All(Dates),
Dates[Year] = previousYear)
)
or ------
Net Value =
VAR previousYear = MAX(Dates[Year]) -1
RETURN
Calculate(
SUM(Sales[NetValue]),FILTER(ALLSELECTED(Dates),
Dates[Year] = previousYear)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

if you write it like this what do you get ?
Net Value =
VAR previousYear = MAX(Dates[Year]) -1
RETURN
previousYear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

If I use that measure in a chart bar where the x-axis is the year, it returns properly the previous year for ech year
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

pls try this
Net Value =
VAR previousYear = MAX(Dates[Year]) -1
RETURN
Calculate(
SUM(Sales[NetValue]),FILTER(All(Dates),
Dates[Year] = previousYear)
)
or ------
Net Value =
VAR previousYear = MAX(Dates[Year]) -1
RETURN
Calculate(
SUM(Sales[NetValue]),FILTER(ALLSELECTED(Dates),
Dates[Year] = previousYear)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I get 2023, which is the expected value since in the example the max is 2024

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
08-08-2024 10:34 PM | |||
01-26-2024 04:56 AM | |||
06-28-2024 11:37 AM | |||
Anonymous
| 03-15-2023 01:00 PM | ||
02-08-2024 07:24 AM |
User | Count |
---|---|
83 | |
80 | |
47 | |
37 | |
37 |