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 || 50+Power Query List Functions : Learn Power Query List
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 || 50+Power Query List Functions : Learn Power Query List
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
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show episode 9

The Power BI Community Show

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

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors