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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
basketballer202
Frequent Visitor

MTD function based of week num

Hi Team,

 

Looking for a little guidance.  I'd like to calculate MTD revenue using week numbers that are tied to a month

 

So for example:

 

Month 1 = week 1/2/3/4

 

Month 2 = week 5/6/7/8/9

 

- If i select week 3, i'd like the MTD revenue from week 1/2/3

- If i select week 8, i'd like the MTD revenue from week 5/6/7/8

 

I have a table that associates every week to a given month.  

 

Would you happen to know what functions/resources i could use to help me achieve this?

 

Thanks in advance!

 

Ray

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@basketballer202 , if week and month are part of date table , you can get it using time intelligence

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

 

MTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @basketballer202 ,

I created some data:

vyangliumsft_0-1658126369247.png

Here are the steps you can follow:

1. Create measure.

Flag =
var _select=SELECTEDVALUE('Slicer'[Week])
var _selectmonth=CALCULATE(MAX('Table'[Month]),FILTER(ALL('Table'),'Table'[Week]=_select))
return
IF(
    MAX('Table'[Month])=_selectmonth&&MAX('Table'[Week])<=_select,1,0)
Measure =
SUMX(ALLSELECTED('Table'),[Amount])

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1658126369247.png

3. Result:

vyangliumsft_2-1658126369251.png

 

If you need pbix, please click here.

 

Best Regards,

Liu Yang

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

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your data model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope this provides some idea on how to create a solution for your data model.

 

Untitled.png

 

 

Sales: = 
SUM( Sales[Revenue] )

 

 

 

Sales MTD: =
IF (
    HASONEVALUE ( 'Calendar'[Month] ),
    CALCULATE (
        [Sales:],
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[Month] = MAX ( 'Calendar'[Month] )
                && 'Calendar'[Week] <= MAX ( 'Calendar'[Week] )
        )
    )
)

 

 

In case if year column matters, please also put the condition that looks for the same year as well.

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@basketballer202 , if week and month are part of date table , you can get it using time intelligence

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

 

MTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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