Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
natasha519
Helper II
Helper II

Create Measure with LatestDate Minus 1 Year

I have a column called 'Date' and it has dates all the way till April 2021. I then created a measure called 'Latest Date' with the following formula:

LatestDate = VAR LatestDate = CALCULATE(MAX(Table[Date]), ALL(Table)) RETURN IF (MIN(Table[Date]) = LatestDate, 1,0)
 
This provides me with a 1 for April 2021 since it is the latest date. I now want to do the same thing but this time I want it to be the latest date minus 1 year, so April 2020. 
 
How can I create a measure that has a 1 for April 2021 (from LatestDate measure) and 1 for April 2020 (LatestDate - 1)?
1 ACCEPTED SOLUTION

@natasha519  do you mean this, pbix is attached

 

forTOPN = 
IF (
    'Table'[Date] = CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Table' ) )
        || 'Table'[Date]
            = CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Table' ) ) - 365,
    1,
    0
)

 

 

smpa01_0-1637700528336.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

5 REPLIES 5
natasha519
Helper II
Helper II

I tried this:

LastYear =
VAR LatestDate = CALCULATE(MAX(Provisional_Data[Date]), ALL(Provisional_Data))
RETURN IF (MIN(Provisional_Data[Date]) = LatestDate-365,1,0)
 
But this only gives me a 1 for April 2020. I now want a 1 in BOTH April 2020 and where the LatestDate =1 so I can use Top N
smpa01
Super User
Super User

@natasha519  can you try htis

 

Measure = 
VAR LatestDate = CALCULATE(MAX('Table'[Date]), ALL('Table')) 
VAR _x = IF (MIN('Table'[Date]) = LatestDate,LatestDate-365)
RETURN _x

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

I would want a 1 in the new column, so 1 for April 2020 and then 1 for April 2021, and the rest of the values would be 0

@natasha519  do you mean this, pbix is attached

 

forTOPN = 
IF (
    'Table'[Date] = CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Table' ) )
        || 'Table'[Date]
            = CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Table' ) ) - 365,
    1,
    0
)

 

 

smpa01_0-1637700528336.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@natasha519 did you have a chance to look into the solution I provided?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.