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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Optimusprime_25
Resolver I
Resolver I

Calculate MTD QTD YTD measures based on Selected Date in a Slicer

Hi,

 

We have two columns  Sales and Date in a table.

We have a requirement where we need to show MTD, QTD and YTD for Sales column in matrix visual based on a selected date.

 

  Date10/05/2022
CategoryYTD SalesQTD Sales

MTD

Sales

A1007025
B15010035
C1208030

 

Here in the Matrix

YTD column should calculate Sales from 01/01/2022 - 10/05/2022

QTD column should calculate Sales from 01/04/2022 - 10/05/2022

MTD column should calculate Sales from 01/05/2022 - 10/05/2022

 

Can anyone help me out?
Thanks in advance.

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@Optimusprime_25 , You can use datesqtd, datesmtd, and datesytd with the date table

 

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

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))

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

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Power BI — Qtr on Qtr with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
https://www.youtube.com/watch?v=8-TlVx7P0A0
Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

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  Thanks for your prompt response.

 

Sorry, I didn't mention in the post, we have drill down on category, when we drill down Sales should come as depicted below in the table.

 

YTD will display all fields from January to selected date, QTD should display only those fields which are applicable for that quarter and MTD should display only those fields which are applicable for that month.

Sales should come as blank if any field sales is not present in QTD and MTD Sales.

 

CategoryYTDQTDMTD
A1007525
A125 25
A22525 
A32020 
A43030 
B15010035
B12525 
B2353535
B31010 
B480  

 

Thanks you.

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!

December 2024

A Year in Review - December 2024

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