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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mithunt
Frequent Visitor

Help needed to create Calculated Column in finding Max\Min\Average for Last Month

Dear PowerBians

 

I would need some assistance in finding a solution on how to implement below using Calculated Column.

I was able to create using Calulate([Sales],PREVIOUSMONTH([Date])) however it gives as a value and I would like to use it as column for more calculations. Any help would be greatly appretiated. 

 

DateSalesMax of Last MonthMin of Last Month
1/1/2022110  
1/2/2022190  
1/3/2022138  
1/4/2022153  
1/5/2022136  
1/6/2022127  
1/7/2022138  
1/8/2022101  
1/9/2022192  
1/10/2022138  
1/11/2022104  
1/12/2022115  
1/13/2022148  
1/14/2022104  
1/15/2022184  
1/16/2022167  
1/17/2022144  
1/18/2022161  
1/19/2022154  
1/20/2022194  
1/21/2022159  
1/22/2022123  
1/23/2022173  
1/24/2022194  
1/25/2022108  
1/26/2022134  
1/27/2022135  
1/28/2022138  
1/29/2022169  
1/30/2022111  
1/31/2022177  
2/1/2022122194101
2/2/2022192194101
2/3/2022197194101
2/4/2022198194101
2/5/2022114194101
2/6/2022156194101
2/7/2022175194101
2/8/2022130194101
2/9/2022141194101
2/10/2022104194101
2/11/2022132194101
2/12/2022170194101
2/13/2022146194101
2/14/2022116194101
2/15/2022122194101
2/16/2022191194101
2/17/2022167194101
2/18/2022160194101
2/19/2022134194101
2/20/2022157194101
2/21/2022112194101
2/22/2022179194101
2/23/2022118194101
2/24/2022125194101
2/25/2022128194101
2/26/2022117194101
2/27/2022179194101
2/28/2022104194101
2 ACCEPTED SOLUTIONS
CNENFRNL
Community Champion
Community Champion

I opt for non-context-transition func, typically date/time func instead of Time Intelligent funcs in a calculated column in order to avoid "undermining" intrinsic row context or unnecessary filter context altering.

Min LM = 
VAR __eolm = EOMONTH( EDATE( DATA[Date], -1 ), 0 )
RETURN
    MINX( FILTER( DATA, EOMONTH( DATA[Date], 0 ) = __eolm ), DATA[Sales] )

CNENFRNL_1-1652565398759.png

 

Excel worksheet formula is powerful enough,

CNENFRNL_2-1652565494155.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

You are welcome! Would you be able to mark my reply as solved? Thanks!!

View solution in original post

5 REPLIES 5
CNENFRNL
Community Champion
Community Champion

I opt for non-context-transition func, typically date/time func instead of Time Intelligent funcs in a calculated column in order to avoid "undermining" intrinsic row context or unnecessary filter context altering.

Min LM = 
VAR __eolm = EOMONTH( EDATE( DATA[Date], -1 ), 0 )
RETURN
    MINX( FILTER( DATA, EOMONTH( DATA[Date], 0 ) = __eolm ), DATA[Sales] )

CNENFRNL_1-1652565398759.png

 

Excel worksheet formula is powerful enough,

CNENFRNL_2-1652565494155.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Whitewater100
Solution Sage
Solution Sage

Hi:

Here's the file (ignore yesterday qty table). I added date table, fyi.

https://drive.google.com/file/d/1clTMZ_Uasovmi_W9cxuD9RDBsvGrgfck/view?usp=sharing 

Whitewater100
Solution Sage
Solution Sage

Hi:

You can first add a calc col for month.(could be a variable) If it's a mutli-year observation then add calc col for month-yr. I am just adding the month in so you can see.

*I'm calling your table ,"Table"

Month = MONTH('Table'[Date])
Min of L Month =
CALCULATE(MIN('Table'[Sales]),PREVIOUSMONTH('Table'[Date]),ALLEXCEPT('Table','Table'[Month]))
Max of L Month =
CALCULATE(Max('Table'[Sales]),PREVIOUSMONTH('Table'[Date]),ALLEXCEPT('Table','Table'[Month]))
I hope this is what you need..
Whitewater100_0-1652559260858.png

 

Thank you very much Whitewater, I was able to create the colum as required. 

You are welcome! Would you be able to mark my reply as solved? Thanks!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.