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
clarkpaul
Helper I
Helper I

MTD Sales by Category Workdays

Our Sales Dept produces a sales ratio calendar that excludes weedends and holidays.
The ratios start small at the beginning of the month and reaches 100% at the end of the month.
The monthly forecast is multiplied by the ratio to track their progress on a daily basis.

My PBI report works fine for an item but has the wrong number for a category:

clarkpaul_0-1624885939680.png

In the example above the MTD Sales is 137 for 17 Jun but it should be 137 + 83 = 220
This is the link to the PBI Report on OneDrive:

https://1drv.ms/u/s!Aq5dyjpfjB3UgYhu2_W4JQPq4inhJQ?e=jfu2sI

Any help would be greatly appreciated!

 

 

 

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

Hi, @clarkpaul ;

You could modify the MTD Sales column as follows:

MTD Sales2 = 
var _a=CALCULATE(SUM([Sales]),FILTER(ALLEXCEPT('Sales','Sales'[Category]),[Date]<=EARLIER(Sales[Date])))
var _b=CALCULATE(SUM([Sales]),FILTER(ALLEXCEPT('Sales','Sales'[Item]),[Date]<=EARLIER(Sales[Date])))
return IF(CALCULATE(DISTINCTCOUNT([Item]),FILTER(ALL(Sales),[Category]=EARLIER([Category])&&[Date]=EARLIER([Date])))=1,_a,_b)

The final output is shown below:

vyalanwumsft_0-1625031769015.png

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, @clarkpaul ;

You could modify the MTD Sales column as follows:

MTD Sales2 = 
var _a=CALCULATE(SUM([Sales]),FILTER(ALLEXCEPT('Sales','Sales'[Category]),[Date]<=EARLIER(Sales[Date])))
var _b=CALCULATE(SUM([Sales]),FILTER(ALLEXCEPT('Sales','Sales'[Item]),[Date]<=EARLIER(Sales[Date])))
return IF(CALCULATE(DISTINCTCOUNT([Item]),FILTER(ALL(Sales),[Category]=EARLIER([Category])&&[Date]=EARLIER([Date])))=1,_a,_b)

The final output is shown below:

vyalanwumsft_0-1625031769015.png

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.

,
  I ran into a problem when there is no sales for a date.  The MTD value disappears:

clarkpaul_0-1625324564722.png

I updated the PBI with the new data:

https://1drv.ms/u/s!Aq5dyjpfjB3UgYhxIrpOVz_n7WzpYQ?e=a8hVTF

 

Thank you very much!!!

amitchandak
Super User
Super User

@clarkpaul , are you using datesmtd with date table ?

 

example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

 

Amitchandak,

I added your recommendation as

MTD Sales B = CALCULATE(SUM('Sales'[Sales]),DATESMTD('Date Table'[Date]))
and renamed it to MTD Sales B for comparison.
 Below is what I get for MTD Sales B.  The correct answer should be 220
clarkpaul_0-1624895578368.png

Thanks

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.