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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
joshua1990
Post Prodigy
Post Prodigy

SUM last business month

Hello everybody!

I would like to sum all the values for the last business month.

The business months have individual start and end dates.

That means I can't use previousmonth function.

 

How can I transfer that code for business months?

=var currentMonth = Month(today())-1
Return
CALCULATE(sum('DB'[Values]);'Calendar'[Business Month Number] = currentMonth)

 

1 REPLY 1
OwenAuger
Super User
Super User

Hello @joshua1990 

 

Is Business Month Number a sequential value increments by one for each month across multiple years (for example Year*12 + Month)?

If it's not, I suggest you create such a column in 'Calendar' first.

 

Once you do you have such a Business Month Number column, you could write something like this:

=
VAR currentMonth =
    CALCULATE (
        MAX ( 'Calendar'[Business Month Number] );
        'Calendar'[Date] = TODAY ();
        ALL ( 'Calendar' ) // Not required if 'Calendar' is marked as a date table
    ) - 1
RETURN
    CALCULATE (
        SUM ( 'DB'[Values] );
        'Calendar'[Business Month Number] = currentMonth;
        ALL ( 'Calendar' )
    )

 

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.