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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Show rolling 12 months sale to last calendar month (january)

Hi, I have this measure for 12 months rolling sales:

CALCULATE(
SUM('Sales'[Sales_Amount_Actual]),
DATESBETWEEN(Date[Date],
NEXTDAY(SAMEPERIODLASTYEAR(LASTDATE(Date[Date]))),
LASTDATE(Date[Date])
)

The problem is that it includes the current month (february), and I dont want the visual to show that.
r12 graf.PNG

How can I put in some kind of lastcalendarmonth function, so that it stops at 2021/Jan, and when february is over 2021/Feb will be included in the graph, and so on..?

Appriciate any help!


2 REPLIES 2
stevedep
Memorable Member
Memorable Member

I suggest to look at the endofmonth function, so go one month back and then endofmonth as your boundary.

https://docs.microsoft.com/nl-nl/dax/endofmonth-function-dax 

Hope it helps. Kind regards, Steve. 

rfigtree
Resolver III
Resolver III

hi havnt tried but maybe something like this.

might get funky if your calendar is not complete?

 

var minDate=EOMONTH(MAX('Calendar'[Date]),-13)
var fromDate=DATE(YEAR(minDate),MONTH(minDate),1)
var toDate=EOMONTH(MAX('Calendar'[Date]),-1)
return	
      CALCULATE(SUM(Table2[value]),
                 FILTER(ALL('Calendar'),  
                       'Calendar'[Date]>=fromDate &&
                       'Calendar'[Date]<=toDate
                 )
      )

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors