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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
samblackshaw28
Frequent Visitor

Calculated DAX for Current Month

Hi All,

 

I was wondering if there was a way to use the calculate function to calculate for current month. I know you can create a calculated column in the data set for this but i'd rather not add a whole column for just 'current month' true/false.

What i'm trying to do is calculate the income but only for the current month. In my head I thought I could do something like:

Calculate(
     [Income],
     ('Report'[Income Date],Month(Today))
)

But this doesn't work.
I also know I can just add a filter on the visuals but I'm going to reuse this measure so would rather it was consistent everywhere.

 

Does anyone know what the correct DAX is for this and if it's even possible?

Thankyou for your help.

  

1 ACCEPTED SOLUTION
v-nuoc-msft
Community Support
Community Support

Hi @samblackshaw28 

 

@sjoerdvn @Gabry Thank you very much for your prompt reply, please allow me to share some content here.

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“Report”

vnuocmsft_0-1722841450323.png

 

Create a measure.

 

Measure = 
var _today= TODAY()
RETURN
CALCULATE(
    SUM('Report'[Income]),
    FILTER(
        ALL('Report'),
        MONTH('Report'[Income Date]) = MONTH(_today) 
        &&
        YEAR('Report'[Income Date]) = YEAR(_today)))
        

 

Here is the result.

 

vnuocmsft_1-1722841537391.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-nuoc-msft
Community Support
Community Support

Hi @samblackshaw28 

 

@sjoerdvn @Gabry Thank you very much for your prompt reply, please allow me to share some content here.

 

For your question, here is the method I provided:

 

Here's some dummy data

 

“Report”

vnuocmsft_0-1722841450323.png

 

Create a measure.

 

Measure = 
var _today= TODAY()
RETURN
CALCULATE(
    SUM('Report'[Income]),
    FILTER(
        ALL('Report'),
        MONTH('Report'[Income Date]) = MONTH(_today) 
        &&
        YEAR('Report'[Income Date]) = YEAR(_today)))
        

 

Here is the result.

 

vnuocmsft_1-1722841537391.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sjoerdvn
Super User
Super User

Instead of using DAX, you could also simply filter your visual or page. For date fields you will see relative date filter options.

sjoerdvn_0-1722513507153.png

What I tend to do however is to have a date dimension with a calculated "relative month" column, where 0 is the current and -1 the previous, so you can easily create filters and measures for current mont, previous month, last 12 months etc.

Gabry
Super User
Super User

Hello,

it depends on what you really want to do and how it is built your calendar table.

 

That said, you can use the function totalmtd.

 

Or for example if you have year and month columns in the calendar table you could write like this

 

calculate(income, calendar[month]=month(today()), calendar[year]=year(today()))

 

Hope this help you

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.