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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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