Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Live now!
I want to get the last 6 months sales ending on the last day of last month from the current date. Following code is what I use. Is there any better suggestion to improve this?
6M pri sales value =
CALCULATE (
SUM ( FactPrimarySales[NetValue] ),
DATESINPERIOD (
DimDate[Date],
CALCULATE (
LASTDATE ( DimDate[Date] ),
DimDate[MonthNo]
= MONTH ( TODAY () ) - 1,
DimDate[Year] = YEAR ( TODAY () )
),
-6,
MONTH
)
)
Solved! Go to Solution.
@Anonymous , Try a measure like this with help from date table
Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),-1),-6,MONTH))
Hi,
If today is December 25, 2020, then i assume that "last day of last month from the current date" should mean 6 months ended November 30, 2020. If my assumption is correct, then try this measure:
=calculate(sum(Sales[Sales Amount]),datesbetween(calendar[date],EDATE(EOMONTH(today(),-1)+1,-6),EOMONTH(today(),-1)))
Hope this helps.
Hi,
If today is December 25, 2020, then i assume that "last day of last month from the current date" should mean 6 months ended November 30, 2020. If my assumption is correct, then try this measure:
=calculate(sum(Sales[Sales Amount]),datesbetween(calendar[date],EDATE(EOMONTH(today(),-1)+1,-6),EOMONTH(today(),-1)))
Hope this helps.
@Anonymous , Try a measure like this with help from date table
Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),-1),-6,MONTH))
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 46 | |
| 45 | |
| 33 | |
| 33 | |
| 30 |
| User | Count |
|---|---|
| 136 | |
| 116 | |
| 58 | |
| 58 | |
| 56 |