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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Bwendos_Den
Frequent Visitor

How to calculate Total Sales showing only until the month before current month

Hi All,

 

I have 3 different table CL (end date, contract id), sales actual ( #actual, dateid, contract id, doc date), and calendar (dateid, year, month, date).

 

They are related like the photo below.

Bwendos_Den_0-1715581475960.png

What I want is that, when I select a month year from calendar, to have sales actual where the End date from CL is until the month before the selected month.

 

do you have any idea on how to solve it?

 

thank you very much for your help

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Bwendos_Den ,

 

The sample measure below will calculate the sales up to before the earliest date of the selected month from the  calendar table.

CALCULATE (
    [sales measure],
    FILTER ( ALL ( 'calendar' ), 'calendar'[Date] < MIN ( 'calendar'[Date] ) )
)

Take note, the sales will be cumulative from the earlierst transaction date. If for just  the current year, try:

CALCULATE (
    [sales measure],
    FILTER (
        ALLEXCEPT ( 'calendar', 'calendar'[YEAR] ),
        'calendar'[Date] < MIN ( 'calendar'[Date] )
    )
)

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
Bwendos_Den
Frequent Visitor

Hi @danextian thanks for your answer but it is not what what I am looking for, with that I still get the current month

Mmm. That is unexpected. Can you please post a workable sample data (not an image) or a sanitized copy of your pbix. You can post a link to a file in the cloud.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Hi @Bwendos_Den ,

 

The sample measure below will calculate the sales up to before the earliest date of the selected month from the  calendar table.

CALCULATE (
    [sales measure],
    FILTER ( ALL ( 'calendar' ), 'calendar'[Date] < MIN ( 'calendar'[Date] ) )
)

Take note, the sales will be cumulative from the earlierst transaction date. If for just  the current year, try:

CALCULATE (
    [sales measure],
    FILTER (
        ALLEXCEPT ( 'calendar', 'calendar'[YEAR] ),
        'calendar'[Date] < MIN ( 'calendar'[Date] )
    )
)

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors