Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

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. 

Appreciate your help.

Thank you!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

 

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.

View solution in original post

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

 

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.

Jihwan_Kim
Super User
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.

 

Untitled.png

 

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.

Anonymous
Not applicable

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

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.

amitchandak
Super User
Super User

@Anonymous , 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))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.