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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Return total values of last month (no date)

I have this table

Fotoprueba.png

 

I want to create a column that gets the total value of every previous month, like this

Fotoprueba.png

 

My DAX formula is the next one:

 

Total value of previous month = 

VAR PreviousMonth = SUM(Hoja1[Month]) - 1

RETURN
CALCULATE(COUNTROWS(Hoja1), Hoja1[Month] = PreviousMonth)

 

 

This is what I get

Fotoprueba.png

 

How can I fix my DAX formula so I get what I need?

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

Is this a measure or a calculated column??If the latter:

Total value of previous month = 
VAR PreviousMonth = Hoja1[Month] - 1
RETURN
CALCULATE(SUM(Hoja1[Value]), Hoja1[Month] = PreviousMonth, ALL(Hoja1))

although it would be wise to use year as well, not only month. What happens if Month = 1?

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

1 REPLY 1
AlB
Community Champion
Community Champion

Hi @Anonymous 

Is this a measure or a calculated column??If the latter:

Total value of previous month = 
VAR PreviousMonth = Hoja1[Month] - 1
RETURN
CALCULATE(SUM(Hoja1[Value]), Hoja1[Month] = PreviousMonth, ALL(Hoja1))

although it would be wise to use year as well, not only month. What happens if Month = 1?

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

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.