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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
slyfox
Helper II
Helper II

MoM sales volume

Hello,

 

Im looking for the formula which can return MoM sales based on MTD number of days.
for exampls If today 09-Aug, I would like to see sum of sales previous month to date 09-Jul.


Data model simple Sales volume table <-> Date Callendar  

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

Hi @slyfox,

 

Based on my test, we can take the following steps to meet your requirement.

 

1.Enter the data and create relationship between Sales volume table and Date Callendar table.

 

2.create a measure as below to get the excepted result.

 

pre = var 
dat = SELECTEDVALUE('Date Callendar'[Date])
return 
IF(ISFILTERED('Date Callendar'[Date]),IF(MONTH(dat)=1,CALCULATE(SUM('Sales volume'[sales]),FILTER(ALL('Sales volume'), DATE(YEAR(dat)-1,12,1)<='Sales volume'[date] && 'Sales volume'[date] <=DATE(YEAR(dat)-1,12,DAY(dat)))),CALCULATE(SUM('Sales volume'[sales]),FILTER(ALL('Sales volume'), DATE(YEAR(dat),MONTH(dat)-1,1)<='Sales volume'[date] && 'Sales volume'[date] <=DATE(YEAR(dat),MONTH(dat)-1,DAY(dat))))),BLANK())

222.png

For more details, please check the pbix as attached. If it doesn’t meet your requirement, kindly share me sample data of your table and tell me what is your excepted result.

 

https://www.dropbox.com/s/kwrf61knwqjbe0q/MoM%20sales%20volume%202.pbix?dl=0

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @slyfox,

 

Based on my test, we can take the following steps to meet your requirement.

 

1.Enter the data and create relationship between Sales volume table and Date Callendar table.

 

2.create a measure as below to get the excepted result.

 

pre = var 
dat = SELECTEDVALUE('Date Callendar'[Date])
return 
IF(ISFILTERED('Date Callendar'[Date]),IF(MONTH(dat)=1,CALCULATE(SUM('Sales volume'[sales]),FILTER(ALL('Sales volume'), DATE(YEAR(dat)-1,12,1)<='Sales volume'[date] && 'Sales volume'[date] <=DATE(YEAR(dat)-1,12,DAY(dat)))),CALCULATE(SUM('Sales volume'[sales]),FILTER(ALL('Sales volume'), DATE(YEAR(dat),MONTH(dat)-1,1)<='Sales volume'[date] && 'Sales volume'[date] <=DATE(YEAR(dat),MONTH(dat)-1,DAY(dat))))),BLANK())

222.png

For more details, please check the pbix as attached. If it doesn’t meet your requirement, kindly share me sample data of your table and tell me what is your excepted result.

 

https://www.dropbox.com/s/kwrf61knwqjbe0q/MoM%20sales%20volume%202.pbix?dl=0

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @slyfox,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case please.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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