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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
DrewSmith
Helper III
Helper III

Previous months orders with date filter in one table.

In PowerBI I'm trying to calculate last months sales. I have a slicer for the date and this is where it's becoming stuck, I think. 
All data is in one table and I'm trying to essentailly calculate the sum of sales orders, if the include/exclude = Include, and the dates are one month prior to that selected on the slicer. 

I've tried:

Orders LM =
CALCULATE(
    SUM(Orders[quantity]),
    DATESBETWEEN(
        Orders[_Use Date],
        EOMONTH(TODAY(),-2)
        EOMONTH(TODAY(),-1)
    ),
    Orders[Include/Exclude] = "Include"
)
 
Which works, but it's not dynamic. A snippit of what the data looks like is below (drafted in Excel). 

 

DrewSmith_0-1702570902538.png

 

1 ACCEPTED SOLUTION

Hi @ryan_mayu . 
Your answer gave me an idea and this worked: 

CALCULATE(sum(Orders[_SalesRev]), DATEADD(FILTER(DATESMTD(_Calendar[Date]), _Calendar[Date]<TODAY()), -1,MONTH))

View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@DrewSmith 

maybe try this

 

Orders LM =
CALCULATE(
    SUM(Orders[quantity]),
    DATESBETWEEN(
      all(  Orders[_Use Date]),
        EOMONTH(selectedvalue(date),-2)
        EOMONTH(selectedvalue(date),-1)
    ),
    Orders[Include/Exclude] = "Include"
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu . 
Your answer gave me an idea and this worked: 

CALCULATE(sum(Orders[_SalesRev]), DATEADD(FILTER(DATESMTD(_Calendar[Date]), _Calendar[Date]<TODAY()), -1,MONTH))

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.