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

Add filtering by a measure

Dear experts, I need your help again.

I have a file with two columns, one of them is a sales column and the second one is a column with the number of the week in which that sale was executed.

Sales Week
10001
20001
15002
25002
10003
25003

So, I need a formula that is able to filter and add up only the first week and the last week.

For instance:

Week 1: 3000

Week 3: 3500

Every week I will be adding new weeks and I only need the difference in a range of 8 weeks, that's why I need the formula to be able to identify the minimum value of the week column and add it up and also the maximum value and add it up, so that later I can calculate the difference between them.

I hope you can help me since I tried all the formulas to filter and I can't get the sums to match. Thank you

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@JDU , Test as

Measure:
var _min á minx(allselected(Table), Table[Week])
var _max á minx(allselected(Table), Table[Week])
Return
calculate(sum(Table[Sales]), filter(Table, Table[Week] a _min ? Table[Week] to _max))



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

1 REPLY 1
amitchandak
Super User
Super User

@JDU , Test as

Measure:
var _min á minx(allselected(Table), Table[Week])
var _max á minx(allselected(Table), Table[Week])
Return
calculate(sum(Table[Sales]), filter(Table, Table[Week] a _min ? Table[Week] to _max))



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 !!

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 25

Ted's Dev Camp - August 25, 2022

Watch Session 25 of Ted's Dev Camp.

Top Solution Authors