Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

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

 

  • Anonymous

    Try this calculated column:

     

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

7 Replies

  • danb's avatar
    danb
    Icon for Resolver I rankResolver I

    Anonymous

    Try this calculated column:

     

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

    • Anonymous's avatar
      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?

      • danb's avatar
        danb
        Icon for Resolver I rankResolver I

        Anonymous

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      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!