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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
mithunt
Frequent Visitor

Help with Calculated Column

Hello All,

 

I am looking for some assistance in finding a calculated column which gives me results as specified in column Sales at Last date(Previous Month) 

 

I have used this DAX and it pulls the latest value instead of last value from last month date

 

pms = CALCULATE(MAXX('Data','Data'[Sales]), 'Data'[Product]=EARLIER('Data'[Product]),'Data'[Last Date of Month],ALLEXCEPT('Data','Data'[Date]))
 
 
Here is the format which I am looking for
 
DateProductSalesLast date of MonthSales at Last date(Previous Month)
3/22/2022Cycle1852/28/2022 
3/23/2022Cycle1182/28/2022 
3/24/2022Cycle1532/28/2022 
3/25/2022Cycle1032/28/2022 
3/26/2022Cycle1452/28/2022 
3/27/2022Cycle1892/28/2022 
3/28/2022Cycle1832/28/2022 
3/29/2022Cycle1152/28/2022 
3/30/2022Cycle1942/28/2022 
3/31/2022Cycle1052/28/2022 
4/1/2022Cycle1973/31/2022105
4/2/2022Cycle1903/31/2022105
4/3/2022Cycle1053/31/2022105
4/4/2022Cycle1193/31/2022105
4/5/2022Cycle1523/31/2022105
4/6/2022Cycle1563/31/2022105
4/7/2022Cycle1343/31/2022105
4/8/2022Cycle1263/31/2022105
4/9/2022Cycle1443/31/2022105
4/10/2022Cycle1953/31/2022105
4/11/2022Cycle1413/31/2022105
4/12/2022Cycle1693/31/2022105
4/13/2022Cycle1273/31/2022105
4/14/2022Cycle1743/31/2022105
4/15/2022Cycle1203/31/2022105
4/16/2022Cycle1563/31/2022105
4/17/2022Cycle1203/31/2022105
4/18/2022Cycle1113/31/2022105
4/19/2022Cycle1643/31/2022105
4/20/2022Cycle1603/31/2022105
4/21/2022Cycle1483/31/2022105
4/22/2022Cycle1093/31/2022105
4/23/2022Cycle1473/31/2022105
4/24/2022Cycle1183/31/2022105
4/25/2022Cycle1613/31/2022105
4/26/2022Cycle1813/31/2022105
4/27/2022Cycle1223/31/2022105
4/28/2022Cycle1893/31/2022105
4/29/2022Cycle1743/31/2022105
4/30/2022Cycle1573/31/2022105
5/1/2022Cycle1714/30/2022157
5/2/2022Cycle1424/30/2022157
5/3/2022Cycle1744/30/2022157
5/4/2022Cycle1964/30/2022157
5/5/2022Cycle1194/30/2022157
5/6/2022Cycle1884/30/2022157
5/7/2022Cycle1854/30/2022157
5/8/2022Cycle1164/30/2022157
5/9/2022Cycle1874/30/2022157
5/10/2022Cycle1604/30/2022157
5/11/2022Cycle1424/30/2022157

 

Thanks all in advance and looking for some assistance here

1 ACCEPTED SOLUTION
daXtreme
Solution Sage
Solution Sage

pms = // calc column
var LastDateOfMonth = 'Data'[Last date of month]
var CurrentProduct = 'Data'[Product]
var Result =
    MAXX(
        filter(
            'Data',
            'Data'[Date] = LastDateOfMonth
            &&
            'Data'[Product] = CurrentProduct
        ),
        'Data'[Sales]
    )
return
    Result

View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

pms = // calc column
var LastDateOfMonth = 'Data'[Last date of month]
var CurrentProduct = 'Data'[Product]
var Result =
    MAXX(
        filter(
            'Data',
            'Data'[Date] = LastDateOfMonth
            &&
            'Data'[Product] = CurrentProduct
        ),
        'Data'[Sales]
    )
return
    Result

Thank you so very much it worked like a charm.. 

 

need to get some experience on writing loops then.. 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.