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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PBIBeginner2022
Helper III
Helper III

Sum after and before the ongoing month in one DAX formula

Hi everyone,

 

I have this formula which calculate the sum of all my PO with type = "PO delivery" :

 

PO Delivery M-1 = CALCULATE(SUM(TPODeliveries[Delivered value in €]), TPODeliveries[Type] = "PO_Delivery")
 
However I want add a filter. I want the sum of all my PO with type = "PO Delivery" except for the ongoing month. I want the sum of all month before the ongoing month and the sum after the ongoing month in one formula.
 
I don't konw if you understand what I search to do. Don't hesitate if we need more information.
 
Thanks in advance for any help.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @PBIBeginner2022 ,

I created some data:

vyangliumsft_0-1657876504633.png

Here are the steps you can follow:

1. Create measure.

sum of all month before the ongoing month =
CALCULATE(SUM('Table'[Delivered value in €]),FILTER(ALL('Table'),
'Table'[Date]>=DATE(
    YEAR(TODAY()),1,1)&&
'Table'[Date]<
DATE(
    YEAR(TODAY()),MONTH(TODAY()),1)))
sum after the ongoing month in one formula =
CALCULATE(SUM('Table'[Delivered value in €]),FILTER(ALL('Table'),
'Table'[Date]>DATE(YEAR(TODAY()),MONTH(TODAY())+1,1)-1&&
'Table'[Date]<=
DATE(
    YEAR(TODAY())+1,1,1)-1
))

2. Result:

vyangliumsft_1-1657876504635.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi  @PBIBeginner2022 ,

I created some data:

vyangliumsft_0-1657876504633.png

Here are the steps you can follow:

1. Create measure.

sum of all month before the ongoing month =
CALCULATE(SUM('Table'[Delivered value in €]),FILTER(ALL('Table'),
'Table'[Date]>=DATE(
    YEAR(TODAY()),1,1)&&
'Table'[Date]<
DATE(
    YEAR(TODAY()),MONTH(TODAY()),1)))
sum after the ongoing month in one formula =
CALCULATE(SUM('Table'[Delivered value in €]),FILTER(ALL('Table'),
'Table'[Date]>DATE(YEAR(TODAY()),MONTH(TODAY())+1,1)-1&&
'Table'[Date]<=
DATE(
    YEAR(TODAY())+1,1,1)-1
))

2. Result:

vyangliumsft_1-1657876504635.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

PBIBeginner2022
Helper III
Helper III

@tackytechtom , @Dhacd 

 

I have a table date with a column MonthYear in format "MMMM YYYY" between "January 1899" to "December 2201". I need to calulate my sum with the specific type on all month of my column MonthYear except the current month -1. Could you help me please

Can you confirm whether the data type for that date column is date or string?

@Dhacd 

My data is in date format

tackytechtom
Super User
Super User

Hi @PBIBeginner2022 ,

 

Maybe something like this?

PO Delivery M-1 = 
VAR _ongoingMonth = MONTH ( TODAY() )
RETURN
CALCULATE ( 
    SUM (TPODeliveries[Delivered value in €]), 
    TPODeliveries[Type] = "PO_Delivery"),
    MONTH ( TPODeliveries[Date] ) = _ongoingMonth 
)

 

You probably need to tweak some parts of the formular with the correct column names of your model etc. Also, I assumed the ongoing month is the same as the current month. I'd suggest to build a date table into your model, too, if you haven't done so.

 

Let me know if this helps 🙂 You may share some example data so it'll be easier to assist you, if things are still unclear.

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

@tackytechtom thanks for your answer. But I don't want the sum of the current month. I want all month except the current month 😃

 

Have you a formula for this ? please

Hi @PBIBeginner2022 ,

 

Oh yeah! I misread. 

 

Have a look in here:

Solved: Not Current Month of Current Year - Microsoft Power BI Community

 

Also, you might wanna consider to do the filtering on the visualisation level. The filter pane has a lot offer in that sense, too 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Dhacd
Resolver III
Resolver III

Hi @PBIBeginner2022,

Have you tried adding the below filter condition in the calculate function?
table[date]<(EOMONTH(today(), -1) + 1)


If this post helps, then please consider accepting it as the solution to help the other members find it more quickly.
Regards,
Atma.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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