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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
smpa01
Super User
Super User

DAX measure to show max of immediately preceding period's value in current period

Hello experts,

My source data is following

namedatevalperiod
a1/1/20201001
a1/1/20202001
a1/2/20203002
a1/2/20204002
a1/3/20205003
a1/3/20206003
b1/1/20207001
b1/1/20208001
b1/2/20209002
b1/2/202010002
b1/3/202011003
b1/3/202012003

 

On a matrix viz I want to show the max of current period's value and what was the max of immediately preceeding period's value. My desired output is following

namedate_maxVal_lastVal
a1/1/20202000
a1/2/2020400200
a1/3/2020600400
b1/1/20208000
b1/2/20201000800
b1/3/202012001000

 

I can't seem to figure out how to come to this. I have tried the following measure

 

Measure 3 = 
VAR _1 = MAX('Table'[period])-1
VAR _2 = CALCULATE(MAXX(FILTER('Table','Table'[period]=_1),'Table'[val]))
RETURN _2

 

but I can't seem to figure out where it is going wrong

Capture.PNG

If you can please would be great.

Thank you in advance.

 

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
1 ACCEPTED SOLUTION
smpa01
Super User
Super User

Sorry figured out by myself..

Measure 3 = 
VAR _1 = MAX('Table'[period])-1
VAR _2 = CALCULATE(MAXX(FILTER('Table','Table'[period]=_1),'Table'[val]),ALLEXCEPT('Table','Table'[name]))
RETURN _2

 

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

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @smpa01 

 

Please try the below measure.

 

Max Val preceeding period =
VAR currentperiod =
MAX ( Data[period] )
RETURN
CALCULATE (
MAX ( Data[val] ),
FILTER ( ALLEXCEPT ( Data, Data[name] ), Data[period] = currentperiod - 1 )
)

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
smpa01
Super User
Super User

Sorry figured out by myself..

Measure 3 = 
VAR _1 = MAX('Table'[period])-1
VAR _2 = CALCULATE(MAXX(FILTER('Table','Table'[period]=_1),'Table'[val]),ALLEXCEPT('Table','Table'[name]))
RETURN _2

 

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors