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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculation dependent on the Value of the previous month

Hi all,

I have a question referring a calculation. The table is bulid as follows:

Rows: "Counterparty"
Colums: "File Date" 
(hierachy from day to year)
Values: "Zinsberechnung"

hbroich_0-1638971864806.png

 


I want to create a measure for the following calculation on a monthly base:

hbroich_1-1638972030512.png

 


If "Sum of previous month" (how to define the variable for the previous month?) > 0, then 0,
If "Value on the first day from the following month" is not 0, than 0, else show the cumulative amount of all values until this day.

Thank you very much for your help!
BR

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

I'm trying to simulate your data, not sure if it's accurate.

Trying to calculate "sum of previous month" with measure is not very comparative. I tried to do some operations with the calculation column to see if it is helpful to you.

month = MONTH('Table'[File Date])
previous month = [month]-1
Sum of previous month =
CALCULATE (
    SUM ( 'Table'[Zinsberechnung] ),
    FILTER (
        ALL ( 'Table' ),
        [Counterparty] = EARLIER ( 'Table'[Counterparty] )
            && [month] = EARLIER ( 'Table'[previous month] )
    )
)
IF = IF([Sum of previous month]>0,"0",BLANK())

vzhangti_1-1639465430139.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

I'm trying to simulate your data, not sure if it's accurate.

Trying to calculate "sum of previous month" with measure is not very comparative. I tried to do some operations with the calculation column to see if it is helpful to you.

month = MONTH('Table'[File Date])
previous month = [month]-1
Sum of previous month =
CALCULATE (
    SUM ( 'Table'[Zinsberechnung] ),
    FILTER (
        ALL ( 'Table' ),
        [Counterparty] = EARLIER ( 'Table'[Counterparty] )
            && [month] = EARLIER ( 'Table'[previous month] )
    )
)
IF = IF([Sum of previous month]>0,"0",BLANK())

vzhangti_1-1639465430139.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. Please show the expected outcome.

Vielen Dank im Voraus.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.