cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
luvagoldenk9
Helper I
Helper I

Measure to Sum Based on Multiple Selections in one Filter

Hello,

 

I am creating a measure to sum dollars by month: 

 

MonthlySum=CALCULATE(SUM('FileYTD'[Sales]),FILTER('FileYTD','FileYTD'[Month]=SELECTEDVALUE('FileYTD'[Month])))

 

Need to add Month as a filter and allow the user the ability to select multiple months or just one month. SELECTEDVALUE only works on one selected month. Any suggestions of how to change the measure to SUM on any number of selected months (or all months, or 3 months based, or whatever months the user selects)?

 

ALLSELECTED does not work either. Any thoughts or ideas would be appreciated. Thank you!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@luvagoldenk9 , first of all if you are selecting month from same table you do not need to add that to filter it should work

CALCULATE(SUM('FileYTD'[Sales]))

 

Above should filter from table and related tables 

 

even if you need a filter then

 

MonthlySum=

var _tab = summarize(allselected('FileYTD') , 'FileYTD'[Month])

return

CALCULATE(SUM('FileYTD'[Sales]),FILTER('FileYTD','FileYTD'[Month] in _tab ))



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@luvagoldenk9 , first of all if you are selecting month from same table you do not need to add that to filter it should work

CALCULATE(SUM('FileYTD'[Sales]))

 

Above should filter from table and related tables 

 

even if you need a filter then

 

MonthlySum=

var _tab = summarize(allselected('FileYTD') , 'FileYTD'[Month])

return

CALCULATE(SUM('FileYTD'[Sales]),FILTER('FileYTD','FileYTD'[Month] in _tab ))



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Thank you amitchandak!

 

The second version you suggested in your response above worked like a champ. Really do appreciate your assistance and help!! 

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors