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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
rahul-opp
Helper I
Helper I

Calculate MTD of current month only without date slicer dependency

Hello
I want to create a line chart comparison between Current Month MTD and Current Month Projected revenue. On report page, there is Date range slicer.
I have created basic Line chart which shows MTD of selected date range.
MTD revenue measure formula used :

 

MTD Revenue =  TOTALMTD([Total Sales], 'Calendar'[Date]) 

 


where [Total Sales] is measure

 

Total Sales =
CALCULATE(
 SUM('Sales'[Total Price])
) 

 


I also tried following formula to restrict date range, but this also didn't worked

 

 

CALCULATE(
   [Total Sales],
   DATESMTD('Calendar'[Date]),
   MONTH('Calendar'[Date]) = MONTH(TODAY()),
   YEAR('Calendar'[Date]) = YEAR(TODAY()),
   REMOVEFILTERS('Calendar'[Date])
)

 


As per this line chart gets generated correctly.
BUT my requirement is, what ever date range selected, Line chart should show CURRENT Month data only. Don't want date slicer selection for Line chart.
I tried to remove Date slicer interactions from Format => Edit interactions , but it breaks line chart.
This is happening because both line chart and date slicer use same 'Calendar'[Date].

Following image of Line chart with date range selected. I want same line chart but without any dependecy of Date Slicer.
Any ideas how to plot line chart without date slicer dependency?

Screenshot 2024-11-06 at 8.40.06 PM.pngScreenshot 2024-11-06 at 8.40.29 PM.png

If I remove date slicer interactions from line chart , it appears as below, which is wrong
Screenshot 2024-11-06 at 9.04.25 PM.png

2 ACCEPTED SOLUTIONS
v-jianpeng-msft
Community Support
Community Support

Thank you johnt75 

Hi, @rahul-opp 

Based on your description and the screenshots you showed, I created the following sample data:

vjianpengmsft_0-1730964962101.png

I also have a date table:

vjianpengmsft_1-1730964986613.png

First, turn off the effect of the slicer on the line chart:

vjianpengmsft_2-1730965009434.png

Next, create a new calculated column in the date table:

Is current Month = 
IF(MONTH('Calendar'[Date]) = MONTH(TODAY()) && YEAR([Date]) = YEAR(TODAY()),1,0)

vjianpengmsft_3-1730965094817.png

Finally, use this calculated column in the line chart:

vjianpengmsft_4-1730965150388.png

When we have data updates, this chart will also dynamically display the MTD for the latest month.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

I can think of a couple of options. You could add a column to your date table like

Today or Before = IF( 'Date'[Date] <= TODAY(), 1 )

and use that as a filter on the visual, in addition to the current month filter.

Or you could amend the measure to return BLANK() if the date is after today.

View solution in original post

6 REPLIES 6
rahul-opp
Helper I
Helper I

hi@v-jianpeng-msft and @johnt75 Thanks for solution. It's new learning for me. I have used both of your suggestions.
@v-jianpeng-msftI have used your solution but it didn't worked. Reason : In your file in Calendar or Date table you have max date is till 7-Nov-2024 and in my calendar i have dates till year end. So it was not working on my end. So I used condition suggested by @johnt75 , I have added 'Calendar'[Date] <= TODAY() in column formula.
Final result is :::
Screenshot 2024-11-07 at 8.30.08 PM.png

This question is only half part of what I want to achieve.
I want to draw line chart comparison between Current Month MTD and Current Month Total Projected revenue.
I need similar result from following link
https://community.fabric.microsoft.com/t5/Desktop/power-bi-Monthly-forecast/td-p/2497222 
veasonfmsft_0-1652347280725.png
Still working on Total projected revenue formula which is combination of MTD and projected revenue. May be I will raise another question in forum for this if I get stuck.
@johnt75 @v-jianpeng-msft If I add MTD and Total projected revenue to my line chart, Does column formula suggested by you will work? Does it give similar output as above image ?
Please share your thoughts.


v-jianpeng-msft
Community Support
Community Support

Thank you johnt75 

Hi, @rahul-opp 

Based on your description and the screenshots you showed, I created the following sample data:

vjianpengmsft_0-1730964962101.png

I also have a date table:

vjianpengmsft_1-1730964986613.png

First, turn off the effect of the slicer on the line chart:

vjianpengmsft_2-1730965009434.png

Next, create a new calculated column in the date table:

Is current Month = 
IF(MONTH('Calendar'[Date]) = MONTH(TODAY()) && YEAR([Date]) = YEAR(TODAY()),1,0)

vjianpengmsft_3-1730965094817.png

Finally, use this calculated column in the line chart:

vjianpengmsft_4-1730965150388.png

When we have data updates, this chart will also dynamically display the MTD for the latest month.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

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

 

 

 

 

 

 

johnt75
Super User
Super User

Try turning off the interactions between the slicer and the line chart, then change the filter on the line chart for the Date column to be relative date, is in the current month.

hi @johnt75 thanks for reply. Your solution restricted date range to current month without date range. It appears as below
Screenshot 2024-11-06 at 10.54.45 PM.png
Is this correct ? I mean it should show line till current day 6-Nov-2024. or it should show all dates of current month as shown in above image.
Currently it shows all dates of current month with last MTD value from 7-Nov onwards.

Any suggestion, any other way,  how to show line chart till current date for example in above image current date is 6-Nov-2024?

I can think of a couple of options. You could add a column to your date table like

Today or Before = IF( 'Date'[Date] <= TODAY(), 1 )

and use that as a filter on the visual, in addition to the current month filter.

Or you could amend the measure to return BLANK() if the date is after today.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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