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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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