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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Peter_au
Helper I
Helper I

MTD Total end date not filtering

Hello,

I am using a date table to calculate a running MTD sum. The sum works, but does not filter the End date for the month as shown below. I got the formula on and is shown below.

 

Any helpful suggestions would be appreciated.

 

Peter_au_0-1593178275083.png

 

Peter_au_1-1593178302034.png

Peter_au_2-1593178327428.png

 

 

Thanks

11 REPLIES 11
nandic
Memorable Member
Memorable Member

Hi Peter,

 

I tested, if i select specific date interval in month, data is displayed inside that interval.

Screenshot below:

When i selected dates (bottom part of image), it filtered these days on list and on chart.

If still doesn't help, feel free to send pbix file and i will check.

 

 

Cumulative until selected date.PNG


Notes: there also might be "conflict" in your report if there are measures which for example have plans, but don't have actuals, these days will always be visible. Example: you filter actuals, but as there are planned values for specific dates, these days are visible.

Cheers,
Nemanja

Hi Nandic,

 

How did you construct your month filter?

 

Do you mind if I send an empty pbix file, without data?

 

 

 

Peter_au_0-1593877863095.png

 

 

Month filter comes from Date dimension and it is in format yyyymm (202001 is January 2020).
List and chart use Date field from Date dimension and created measures.
Measure Cumulative sales: 

Cumulative sales = CALCULATE(SUM(Sales[Sales]),FILTER(ALLSELECTED('Date'),'Date'[Date]<=MAX('Date'[Date])))
Sales = field from Sales table.


Date dimension:
Date dimension.PNG

Sales fact:
Sales fact.PNG

Here is relationship between these tables:
Realationship.PNG

If still not working, you can send screenshots.

Nemanja

Hi Nandic,

 

I have a date table, but it was suggested to use an independant dat table to produce these tables. Should I use my date tables that currently have the proper relationships, as you suggested?

nandic
Memorable Member
Memorable Member

Could you try this approach?

Dax measure: 

Cumulative sales = CALCULATE(SUM(Sales[Sales]),FILTER(ALLSELECTED('Date'),'Date'[Date]<=MAX('Date'[Date])))
If you limit filter to only only one month, it will show you running total for selected month, if you allow multiple select, it will display cumulative amount for whole period.
Screenshot with examples for daily and monthy layout.Cumulative measure.PNG

Hello Nandic,
That is in fact very close to what I would like.
The difference would be that I wlould like the user to pick the date that they want and the graph would show the data from the beginning of the month to that date.

Below is an example of what I am trying to do. You will notice that the data goes beyond the date in the graph.

 

Peter_au_1-1593436615518.pngdateplanplan_crealreal_c

2020-01-0115151515
2020-01-0215302035
2020-01-0315453671
2020-01-04156069140
2020-01-0515758148
2020-01-06159052200
2020-01-071510515215
2020-01-081512012227
2020-01-091513520247
2020-01-101515014261
2020-01-11151655266
2020-01-12151803269
2020-01-13151956275
2020-01-141521015290
2020-01-151522585375
2020-01-161524055430
2020-01-171525523453
2020-01-181527020473
2020-01-191528512485
2020-01-201530015500
2020-01-211531516516
2020-01-221533018534
2020-01-231534522556
2020-01-2415360  
2020-01-2515375  
2020-01-2615390  
2020-01-2715405  
2020-01-2815420  
2020-01-2915435  
2020-01-3015450  
2020-01-3115465  

 

This almost works, but the dates keep going after the end of the month and doesn't work properly with the graph.

 

MTD_Planned_tonnes_2 = calculate([Daily_Tonnes_Plan],filter(ALL(tbl_Tonnes_Tenneur_Plannifier_Jour),
tbl_Tonnes_Tenneur_Plannifier_Jour[Date_Index] >= [SOM]
&& tbl_Tonnes_Tenneur_Plannifier_Jour[Date_Index] <= [EOM]
&& tbl_Tonnes_Tenneur_Plannifier_Jour[Date_Index]<=max(tbl_Tonnes_Tenneur_Plannifier_Jour[Date_Index])
)
)
 
 
 
v-jayw-msft
Community Support
Community Support

Hi @Peter_au ,

 

What's your expected out put? Show MTD from selected date to the end of month?

If so, you can create a mseasure like

IF(selectedvalue(date_index)>[eom],1,0)

Then add this measure to visual filter measure = 1.

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@Peter_au , For such cases, prefer to use time intelligence with a date calendar

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.

The Data table is connected with a many to one relationship to a calander table marked as a date table.

What I am trying to do is have a chart showing the cummulative mtd total for the planning,(showing the full month), comared to the running total MTD of the current data, depending on the day.

nandic
Memorable Member
Memorable Member

Did you try using TOTALMTD function? It should work for month to date results.
Example: 

MTD measure = TOTALMTD([measure],'Date'[Date])
 
Another point of view, you should check data and relationships, it seems dates column is not consistent. Compare date column from Date table and date_index column to see if there are multiple rows per unique date.
 

Hello Nandic, I have a one to many relationship between a date table and the data table, to give consistency.

This is what Totalmtd does

Peter_au_0-1593181649830.png

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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