Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

How to get monthly sum through current date?

I have a calendar table that runs through 2025, and I want to sum the number of business days for all previous months up until the present day in December. How can I write a formula to do this?

 

=
MAXX(
KEEPFILTERS(VALUES('date'[date])),
CALCULATE(SUM('Date'[Business Days Passed]),filter('date','date'[date]=today()-1)))

 

This only shows the total business days in December so far, and shows it for every month which is not what I want. 

 

I would like

September 21

October 22

November 21

December 8

 

  • I'm guessing given how your formula looks that the Business Days Passed column is something that has a 1 if it is a business day and a 0 if it doesn't - how about making a column that compares the date in your date table and populates it with a 1 or a 0 dependent on whether the date in the date table is before today or not? You could then countrows conditional on both column's status, or, equivalently, do a sumx of multiplying the two columns together?

2 Replies

  • jthomson's avatar
    jthomson
    Icon for Solution Sage rankSolution Sage

    I'm guessing given how your formula looks that the Business Days Passed column is something that has a 1 if it is a business day and a 0 if it doesn't - how about making a column that compares the date in your date table and populates it with a 1 or a 0 dependent on whether the date in the date table is before today or not? You could then countrows conditional on both column's status, or, equivalently, do a sumx of multiplying the two columns together?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Oh my god you literally saved me from insanity. I have been too far into this problem I was having to even think of something as simple as that. I wish I could give you 10,000 kudos oh my goodness.