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
Zeesh1979
Regular Visitor

Counting rows

I have table that contains List of items and their sales count on date basis. i created a new column that contains month. now i want to have commulative sum of sales for each month. e.g. if in filter i select March, then it should give me sum of all sales till march (march excluding march) and when i select April then sum of all sales till april (excluding april)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Zeesh1979 ,

I made a simple file, please check the model:

 

Total Sales = 
VAR _month = SELECTEDVALUE('Calendar'[Month])
VAR _total = CALCULATE(SUM('SalesTable'[Sales]),FILTER('SalesTable',_month>MONTH('SalesTable'[Date]))) + 0
RETURN
_total

 

vcgaomsft_3-1665042518928.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

@Zeesh1979 Better Running Total - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

how? can u plz elaborate

@Zeesh1979 Hard to be specific with the amount of information you provided. It should be something along the lines of:

Better RT = 
    VAR __Date = MAX('Table'[Date])
    VAR __Table = FILTER(ALLSELECTED('Table'),[Date] <= __Date)
RETURN
    SUMX(__Table,[Value])

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

surely i will add numeric month column but what would be the final solution?

Anonymous
Not applicable

Hi @Zeesh1979 ,

I made a simple file, please check the model:

 

Total Sales = 
VAR _month = SELECTEDVALUE('Calendar'[Month])
VAR _total = CALCULATE(SUM('SalesTable'[Sales]),FILTER('SalesTable',_month>MONTH('SalesTable'[Date]))) + 0
RETURN
_total

 

vcgaomsft_3-1665042518928.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

ItemSalesMonth
Cars100Jan
Bikes150Feb
Cars50Jan
Bikes120March

 

expected output if March filter selected

Total Sales300

expected output if Feb filter selected

Total Sales150

 

i hope this helps more...(im new to community and learning how to improve asking question)

@Zeesh1979 Yeah, you are really going to want an actual Date column in there otherwise it's going to get really ugly to code because there is no way to numerically figure out "before" and thus you would end up hand coding all of your month values. Super ugly. You could possibly get away with a numeric Month column, 1, 2, 3, 4, etc. if you don't care about years.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.