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

Calculated Column of Sum per Month

Hello!

 

I have a calculation to complete that requires a sum of the current month. Note, I need this to be done with a calculated DAX column, not a measure unfortunately! My calculation is pretty advanced and will be easier if i had this column.

 

To explain more clearly what I am looking for my desired output is shown below as TotalPerMonth:

 

Sales  
DateAmountTotalPerMonth
7/1/2018534
7/1/2018634
7/1/2018734
7/2/2018234
7/2/2018334
7/2/2018334
7/3/2018434
7/3/2018334
7/3/2018134
8/1/2018239
8/1/2018339
8/1/2018339
8/2/2018239
8/2/2018339
8/2/2018539
8/3/2018639
8/3/2018739
8/3/2018839

 

The above table is should portray most of my caveats of my data, however, attached in the spoiler tag is a more rigororus dataset:

 

 

Spoiler
DateAmountTotalPerMonth
5/31/2018 0:0053869.971259637
5/31/2018 1:0054058.041259637
5/31/2018 2:0053270.371259637
5/31/2018 3:0054487.841259637
5/31/2018 4:0054003.491259637
5/31/2018 5:0052144.591259637
5/31/2018 6:0047906.151259637
5/31/2018 7:0049621.781259637
5/31/2018 8:0054271.141259637
5/31/2018 9:0053384.481259637
5/31/2018 10:0050849.781259637
5/31/2018 11:0053899.411259637
5/31/2018 12:0054124.261259637
5/31/2018 13:0053406.911259637
5/31/2018 14:0048970.371259637
5/31/2018 15:0048303.021259637
5/31/2018 16:0052115.21259637
5/31/2018 17:0053370.161259637
5/31/2018 18:0051550.341259637
5/31/2018 19:0051057.451259637
5/31/2018 20:0052635.511259637
5/31/2018 21:0053951.191259637
5/31/2018 22:0054479.151259637
5/31/2018 23:0053906.861259637
6/1/2018 0:0052760.431234373
6/1/2018 1:0052897.11234373
6/1/2018 2:0050640.631234373
6/1/2018 3:0052362.221234373
6/1/2018 4:0051984.251234373
6/1/2018 5:0051791.61234373
6/1/2018 6:0048052.681234373
6/1/2018 7:0049226.491234373
6/1/2018 8:0053700.41234373
6/1/2018 9:0053024.821234373
6/1/2018 10:0052481.091234373
6/1/2018 11:0053542.611234373
6/1/2018 12:0052460.781234373
6/1/2018 13:0052598.761234373
6/1/2018 14:0052573.911234373
6/1/2018 15:0052284.611234373
6/1/2018 16:0052712.141234373
6/1/2018 17:0047793.631234373
6/1/2018 18:0046917.881234373
6/1/2018 19:0048769.641234373
6/1/2018 20:0051219.081234373
6/1/2018 21:0053080.731234373
6/1/2018 22:0050553.361234373
6/1/2018 23:0050944.621234373

 

1 ACCEPTED SOLUTION
danb
Resolver I
Resolver I

@Anonymous

Try this calculated column:

 

TotalPerMonth = CALCULATE(SUM(Table1[Amount]),FILTER(Table1,Table1[Date] = EARLIER(Table1[Date])))

View solution in original post

7 REPLIES 7
danb
Resolver I
Resolver I

@Anonymous

Try this calculated column:

 

TotalPerMonth = CALCULATE(SUM(Table1[Amount]),FILTER(Table1,Table1[Date] = EARLIER(Table1[Date])))

tharris
Frequent Visitor

Hello @danb ,

 

I am trying to accomplish the same thing, however, I do not have an import file, and therefore, cannot create that in power query...or use the EARLIER function as it is not supported for DirectQuery.

 

Do you have any ideas of how to achieve this?

 

Thanks!

Anonymous
Not applicable

Hey @danb!

 

The code you posted creates an error "EARLIER/EARLIEST refers to an earlier row context which doesn't exist."

 

Any Ideas?

@Anonymous

Enter in the formula as a "New Column" and not a "New Measure"

Anonymous
Not applicable

44.PNG

 

Yup, I am entering it as a new column

@Anonymous - it appears that you have some type of error occuring after the "earlier" function. Please see my screenshot below. I have the same column in with the May/June data and it is not tripping the error. 

 

Screenshot_1.png

Anonymous
Not applicable

Yes today is a monday, I was adding it as a measure. Smiley Frustrated

 

Your function works, thank you

 

I had to adjust it a bit however: 

 

I made a new column format(table1[date] , "yyyymm")

 

then filtered using that new column.

 

By filtering by date, it gives the sum/ per day instead of per month. big thanks though!

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.