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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
unnijoy
Post Partisan
Post Partisan

YTD and MTD based on Year and month Filter

I have a sales data for the last 3 years. In my dashboard i have month and year slicer. I placed two cards one for YTD and the other for MTD. I need to show the MTD and YTD slaes based on the below criteria.

1 If all Years are selected then it shoud show Latest year YTD. Same for for MTD

2 If multiple years are selected then YTD should show the total sum based on the year's selected. 

 Same principl for MTD Card also. If all years are slected then it should show the sum of all month slaes in the latest year. And if multiple months are selected then it shoul show the sum of sales based on the month's selected.

 

I have creaetd a clander table by using the below equation. and i am using this for year and month. Please help me to create a formula based on the below calender table.   

 
Clander table =ADDCOLUMNS(
CALENDAR(MIN(Errors[Month_YR]),MAX(Errors[Month_YR])),
"Year",YEAR([Date]),
"Monthn",MONTH([Date]),
"Month",FORMAT([Date],"mmmm"),
"Month Year",FORMAT([Date],"mmm-yy"),
"MonthYearSort",FORMAT([Date],"yyyymm")
)
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@unnijoy , Based on Intital description. I think You need use has one value.

if it has one value then use time intelliegnece else use simple sum measure

 

example Ti measure

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

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

 

for hasonevalue refer : https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
PC2790
Community Champion
Community Champion

Your second requirement can be fulfilled using the below measure:
 
Selection =
var Selectedvalue = if (HASONEVALUE(DatesTable[Year]),VALUES(DatesTable[Year]))
return
CALCULATE(sum(Sales[Sales Amount]),FILTER(Sales,SEARCH(Selectedvalue,Sales[YearValue],1,Blank())))
 
You can further apply if condition tofulfil your 1st condition
amitchandak
Super User
Super User

@unnijoy , Based on Intital description. I think You need use has one value.

if it has one value then use time intelliegnece else use simple sum measure

 

example Ti measure

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

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

 

for hasonevalue refer : https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak ,

 

When i use the month from the calander table that we are using it is not giving me the correct data.

Clander table =ADDCOLUMNS(
CALENDAR(MIN(Errors[Month_YR]),MAX(Errors[Month_YR])),
"Year",YEAR([Date]),
"Monthn",MONTH([Date]),
"Month",FORMAT([Date],"mmmm"),
"Month Year",FORMAT([Date],"mmm-yy"),
"MonthYearSort",FORMAT([Date],"yyyymm")
)
 
"Month Year" is used for month selection. 
How can i use the "YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))" in this case.
 
When i try to use it is givig me error saying Month year is in text format.

Hi @amitchandak ,

 

thanks for your quick help. I tried using the above formula. But when i select multiple month MTD is showing the sum of sals for the latest month in the selected month. For example, if i select Oct -20,Nov -20 & Dec -20. Currently it is showing the Dec-20 sales sum as MTD. Actulay it should show the sales sum of Oct -20+Nov-20+Dec -20. And of all months are select then it should show the latest month sales.

Helpful resources

Announcements
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.