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
Paulyeo11
Impactful Individual
Impactful Individual

How to create expression for last 2 month sales ?

1 ACCEPTED SOLUTION

@Paulyeo11  , YTD was other topics or

You can have rolling of any months by replacing values

Rolling 2 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-2,MONTH))

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

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

View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@Paulyeo11 

do you only consider month? Since i see you circle all Oct and Nov sales amount for both 2019 and 2020.

if I did not misunderstand your request. you can try this

Measure 2 = 
VAR _max=max('SALES'[date])
VAR last1=month(_max)-1
VAR last2=month(_max)-2
RETURN CALCULATE(sum(SALES[sales]),FILTER(SALES,month(SALES[date])in {last1,last2}))

11.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Paulyeo11
Impactful Individual
Impactful Individual

Hi Ryan 

Thank you for your sharing 

Amit expression working fine 

I make some mistake in the image , I only refer to same year 

amitchandak
Super User
Super User

@Paulyeo11 , Try rolling formula, With date table

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

 

If means every month will display 2 months of data '

In case you want two month with any selected date -https://www.youtube.com/watch?v=duMSovyosXE

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

Hi Amit

 

what i need is create a expression for compute last X month . I have change the expression from 12 to 11 , i hope to get YTD sales. Hope you can help me.

 

Paulyeo11_1-1605924324426.png

 

@Paulyeo11  , YTD was other topics or

You can have rolling of any months by replacing values

Rolling 2 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-2,MONTH))

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

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.