cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper III

## Measure to Calculate value from the earliest date until previous month

Hi,

I have sales value column and sales date. I would like to calculate the total value of sales from the earliest sales date until the previous month of the current month regardless its year and month. Example, if the earliest sales date is January 2020 and current date is August 2022, I would like to calculate total sales from January 2020 to July 2022.

Thank you!

1 ACCEPTED SOLUTION
Community Support

Hi, @qhpowerbi ;

You could try it.

``````measure =
CALCULATE (
SUM ( [sales] ),
FILTER (
ALL ( 'table' ),
[category] = "chicken"
&& [date] <= EOMONTH ( TODAY (), -1 )
)
)
``````

Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 REPLIES 5
Community Support

Hi, @qhpowerbi ;

You could try it.

``````measure =
CALCULATE (
SUM ( [sales] ),
FILTER (
ALL ( 'table' ),
[category] = "chicken"
&& [date] <= EOMONTH ( TODAY (), -1 )
)
)
``````

Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

Hi,

I am not sure how your expected outcome looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below can help to provide some ideas on how to create a solution for your dataset.

``````Sales until previous month: =
CALCULATE (
[Sales measure:],
KEEPFILTERS ( Dates[Date] <= EOMONTH ( TODAY (), -1 ) )
)
``````

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Visit my LinkedIn page by clicking here.

Schedule a meeting with me to discuss further by clicking here.

Helper III

how can i do if I want to add another filter along with keepfilters. example calculate(sum(sales), filter('table'[category] = "chicken"))

Super User

Hi,

Thank you for your message, and please share your pbix file's link here, and then I can try to look into it to come up with an accurate solution for your dataset.

Thank you.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Visit my LinkedIn page by clicking here.

Schedule a meeting with me to discuss further by clicking here.

Super User

@qhpowerbi , Try like

LTD =
var _max = eomonth(if(isfiltered('Date'),MAX( 'Date'[Date]) , today()),-1)
var _min = Minx(ALLSELECTED('Date'),'Date'[Date])
return
CALCULATE([net] ,filter('Date', 'Date'[Date]>=_min && 'Date'[Date] <=_max))

LTD =
var _max = eomonth(if(isfiltered('Date'),MAX( 'Date'[Date]) , today()),-1)
var _min = Minx(ALLSELECTED('Date'),'Date'[Date])
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors