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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.