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
Anonymous
Not applicable

Calculate SUM for single value from multi-select slicer

Hey guys,


hope you can help me out with this one.

I have a filter on month names (for simplicity let's imply the year is always 2022): 

SeekingHelp_0-1651139821362.png

And another slicer that allows period selection (MTD/Full). I'm already calculating the sum over the selected period.
Now, what I want to achieve is, that it is only calculating the sum 
and displaying it in a bar chart for the most recent month selected (e.g. March) when the user has MTD selected.


I did the calculation like that: 

CALCULATE (
SUM ( value ),
...
Dates[Year Month Number] = MAX ( Dates[Year Month Number] )
)

That works fine and I'm also able to show the whole sum over all months when the user selects "Full" in the other slicer.
Here is the problem: 
In a bar chart, Max ( Dates[Year Month Number] ) will always refer to the month the bar shows, so it displays all the selected months instead only the most recent one:
SeekingHelp_1-1651140395238.png

 


How do I achieve that it only shows March now?
 
Thanks for your help.
 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Create a measure

 

measure =

var _max = eomonth(maxx(allselected(Dates) , Dates[Date]) ,0)

return

calculate(sum(Table[Value]), filter(Dates, eomonth(Dates[Date],0) =_max)

Share with Power BI Enthusiasts: 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

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Create a measure

 

measure =

var _max = eomonth(maxx(allselected(Dates) , Dates[Date]) ,0)

return

calculate(sum(Table[Value]), filter(Dates, eomonth(Dates[Date],0) =_max)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

Thanks for your reply. Solved my issue with the MTD calculation. But I'm not able to transfer your example to a YTD calculation. If a user selects YTD, I want to show all months of the most recent year in a bar chart, despite the fact that the user might have not selected all months. How do I deal with this?


Appreciate your help!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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