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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ab_99
Frequent Visitor

YTD with month slicer

Hi PBI Community,

I'm stuck with the following issue.


In my report, year and month are selected by using two slicers.
Based on this selection, a graph with YTD values up to the selected month should be displayed - including all previous months from the beginning of the year.
So I need a measure which calculates the YTD values over the month up to the end of the selected month.

How can this be done? 
ab_99_1-1718193673180.png

 

Thanks for your help in advance!

 

Best,

An


 

 

2 ACCEPTED SOLUTIONS

@ab_99 , You need to use the disconnected table in the slicer.

 

//Date1 is independent/disconnected Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -1*month(_max) )
return
calculate( totalmtd(sum(Table[Value]),'Date'[Date]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

 

//Date1 is independent/disconnected Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -1*month(_max) )
return
if(Max('Date'[Date]) >=_min && ('Date'[Date]) <=_max, calculate( sum(Table[Value]),datesmtd('Date'[Date])) )

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Anonymous
Not applicable

Hi @ab_99 ,

Attached is the demo file, and hope this helps you understand @amitchandak 's approach.

vcgaomsft_0-1718263939999.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

6 REPLIES 6
ab_99
Frequent Visitor

@mh2587 thank you for your response! Sadly, its giving this result (as the month slicer is filtering the visual): 

ab_99_0-1718197940083.png

I need the privious months to be displayed too...

 

@ab_99 , You need to use the disconnected table in the slicer.

 

//Date1 is independent/disconnected Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -1*month(_max) )
return
calculate( totalmtd(sum(Table[Value]),'Date'[Date]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

 

//Date1 is independent/disconnected Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -1*month(_max) )
return
if(Max('Date'[Date]) >=_min && ('Date'[Date]) <=_max, calculate( sum(Table[Value]),datesmtd('Date'[Date])) )

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Thank you for the help!

Unfortunately, your solution doesn't work - or maybe I got something wrong. Could you please add some more details to your solution? 

Anonymous
Not applicable

Hi @ab_99 ,

Attached is the demo file, and hope this helps you understand @amitchandak 's approach.

vcgaomsft_0-1718263939999.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

hi, 
Thank you for your demo. It was usefull for me and I solved the problem!! 🙂

mh2587
Super User
Super User

YTD Value = //This might give an idea
VAR SelectedYear = SELECTEDVALUE('Date'[Year])
VAR SelectedMonth = SELECTEDVALUE('Date'[MonthNumber])
RETURN
CALCULATE(
    SUM('YourTable'[Value]),
    FILTER(
        ALL('Date'),
        'Date'[Year] = SelectedYear &&
        'Date'[MonthNumber] <= SelectedMonth
    )
)

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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