This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
I haven't found a workable solution to this. Although this link was promising I couldn't get the answer to work.
https://community.powerbi.com/t5/Desktop/Latest-Month-value/m-p/383443#M174525
What I want to do is very similar. I want to create a card that simply shows the last month of data available for that value. Say it's Invoiced Sales. In the above link I got the first part to work create a column with:
MonthDate = DATE(YEAR([DateField]), MONTH([DateField]), 1)
but when I attempted to create the measure I get errors. It doesn't seem to like the "END" and I'm not a good enough DAX Coder to see what the problem is.
Last Month Sum = VAR endDate = LASTDATE('YourTable'[MonthDate])
END
CALCULATE(
SUM('YourTable'[BudgetValue]),
'YourTable'[MonthDate] = endDate
)The error I get is:
The syntax for 'END' is incorrect. (DAX(VAR endDate = LASTDATE('DIMCalendar'[MonthDate])ENDCALCULATE( SUM('YourTable'[BudgetValue]), 'YourTable'[MonthDate] = endDate))).
Solved! Go to Solution.
Hi @Anonymous
In the Last Month Sum measure, change END to RETURN
This seems to be a typo in the post you referred to.
In general, a sequence of variable declarations with VAR must be followed by RETURN <expression>.
Regards,
Owen
Messed with it a bit to get one that doesn't need the MonthDate column in the date table.
MTD Sales =
VAR MaxDate = MAX ( 'Date'[Date] )
VAR SOMMaxDate = DATE ( YEAR ( MaxDate ) , MONTH ( MaxDate ) ,1 )
VAR EOMMaxDate = EOMONTH( MaxDate , 0 )
RETURN
CALCULATE( SUM('YourTable'[BudgetValue]) ,
FILTER (
ALL ( 'Date'[Date] ),
'Date'[Date] >= SOMMaxDate && 'Date'[Date] <= EOMMaxDate) )
Messed with it a bit to get one that doesn't need the MonthDate column in the date table.
MTD Sales =
VAR MaxDate = MAX ( 'Date'[Date] )
VAR SOMMaxDate = DATE ( YEAR ( MaxDate ) , MONTH ( MaxDate ) ,1 )
VAR EOMMaxDate = EOMONTH( MaxDate , 0 )
RETURN
CALCULATE( SUM('YourTable'[BudgetValue]) ,
FILTER (
ALL ( 'Date'[Date] ),
'Date'[Date] >= SOMMaxDate && 'Date'[Date] <= EOMMaxDate) )
Hi @Anonymous
In the Last Month Sum measure, change END to RETURN
This seems to be a typo in the post you referred to.
In general, a sequence of variable declarations with VAR must be followed by RETURN <expression>.
Regards,
Owen
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 38 | |
| 29 | |
| 28 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 66 | |
| 36 | |
| 29 | |
| 25 | |
| 24 |