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
Anonymous
Not applicable

Quick DAX help for last month and the preceding month values

Hi - I've got a DAX measure to give me the latest availabe data from a sales table

 

Sales Last Month Sum = VAR endDate = LASTDATE('Sales[Date])
RETURN
CALCULATE(
    SUM('Sales'[Value]),
    'Sales'[Date] = endDate
)
 
How do I get a DAX sum to show the value for the month before? I'd then be looking to show the difference in the latest month from the month that preceeded it - is there a way of doing it without having a Calendar table set up? Any help greatly appreciated!
3 REPLIES 3
FreemanZ
Super User
Super User

hi @Anonymous ,

 

Not sure if i fully get you, supposing your sales table look like:

date value
9/1/2023 1
10/1/2023 1
10/2/2023 1
11/1/2023 1
11/2/2023 1
11/3/2023 1
12/1/2023 1
12/2/2023 1
1/1/2024 1
1/2/2024 1
1/3/2024 1
1/4/2024 1

 

try

1) add calculated table like:

dates = 
ADDCOLUMNS(
    CALENDAR(MIN(sales[date]), MAX(sales[date])),
    "yymm", FORMAT([Date], "yy/mm")
)

 

2) relate sales[date] with dates[date]

 

3) plot a table visual with dates[yymm] with a measure like:

TotalPM = 
CALCULATE(
    SUM(sales[value]),
    DATEADD(dates[Date],-1, MONTH)
)

 

it worked like:

FreemanZ_0-1700619498512.png

 

Anonymous
Not applicable

Could you please provide the data table without sensitive information and how you expect the output to look like?

Anonymous
Not applicable

hi - my table is very simple - thanks

 

Apr-2337.9
May-2339.2
Jun-2341.0
Jul-2339.6
Aug-2339.5
Sep-2339.1
Oct-2339.9

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.