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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
juju
Helper III
Helper III

MTD Calculation

 

I am using the formula below to pull the MTD value from the previous day.  I'd like to make the value of the first day of each month blank - so it doesnt pull from the last day of the previous month. I setup a calendar table and tried a couple of filters but none works. Will appreciate some help. 

 

 

        Previous Day MTDCalc = 
        TOTALMTD (
            CALCULATE (
                CALCULATE ( 
                    SUM(FactTable[Value]),
                    FILTER (
                        FactTable,
                        FactTable[Channel]= "MyChannel"
                    )
               )
            ),
            PreviousDay (FactTable[Date])
        )
1 ACCEPTED SOLUTION

All set. Managed to get it working with this :

 

Previous Day MTDcALC = 
IF ( FactTable[Date] = STARTOFMONTH(FactTable[Date]), BLANK(), 
    TOTALMTD (
        CALCULATE (
            CALCULATE ( 
                SUM(FactTable[Value]),
                FILTER (
                    FactTable,
                    FactTable[Channel]= "MyChannel"
                )
           )
        ),
            PreviousDay (FactTable[Date])
        )
    )

 

Thxxxx

View solution in original post

7 REPLIES 7
dkay84_PowerBI
Microsoft Employee
Microsoft Employee

I'm confused though. Why would your MTD calc be pulling in data from the previous month?

I am looking to pull the value of the previous days MTD calculation. But the code I posted pulls the value of the last day of the previous month for the first day of the month .

 

I tried the flag you suggested using a DAY (DateDim[Date]) . The if statement didn't work when I set it to check for value = 1 .  Field just came up blank.  

I will try to play around with this tomorrow but can you confirm that you have a day slicer to choose a day and you want to return a MTD value up to the day prior to the one selected (unless day of month = 1).

All set. Managed to get it working with this :

 

Previous Day MTDcALC = 
IF ( FactTable[Date] = STARTOFMONTH(FactTable[Date]), BLANK(), 
    TOTALMTD (
        CALCULATE (
            CALCULATE ( 
                SUM(FactTable[Value]),
                FILTER (
                    FactTable,
                    FactTable[Channel]= "MyChannel"
                )
           )
        ),
            PreviousDay (FactTable[Date])
        )
    )

 

Thxxxx

Hi @juju,

 

I am very glad to hear you have resolved your problem. Please mark the corresponding replay as answer, which will help other people find solution easily and clearly.

 

Best Regards,
Angelia

Yes - I am trying to calculate it - without using the slicer. But I guess it's th same calculation if I added a day slicer to the report. 

dkay84_PowerBI
Microsoft Employee
Microsoft Employee

Could you add a calc column for "first day of month" flag and then use an IF statement to get what you want? Not sure based on your description but pseudo code would be:

If "flag" is true then start MTD calculation from 0 else MTD calculation

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.