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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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