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
unnipbi123
Helper II
Helper II

How to calculate total sales as of first day of the current month as Previous month sales DAX

I have salesamount column and the saledate column in my table. so I need to calculate total sales for each month based on below calculation.

total sales for current month=sum(salesamount) as of 1st day of the next month

for example sales of December-2021 should be calculated based on the total sales as on Jan-1-2022. total sales for January should be blank until Feb-1-2022 as it should be the total sales as on feb-1-2022. I am very much confused how we can achieve this in Dax. Really appreciate your help.

1 ACCEPTED SOLUTION

@unnipbi123 TRy this:

Measure =
VAR cal_ = CALCULATE(SUM('Table'[Sales]),DATEADD(STARTOFMONTH('Table'[Date]),1,MONTH))
RETURN IF(MONTH(MAX('Table'[Date]))<MONTH(TODAY()),BLANK(),cal_)
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @unnipbi123 ;

You could create a measure.

Measure = IF(MAX([Date])= STARTOFMONTH('Table'[Date]),
             CALCULATE(SUM([value]),FILTER(ALL('Table'),EOMONTH( [Date],0)=EOMONTH(MAX([Date]),-1))))

The final output is shown below:

vyalanwumsft_0-1643260712705.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.

unnipbi123
Helper II
Helper II

@Tahreem24 

 

Thanks for the response. However with the below measure, i am getting data for January month as well since there are some sales for January. So its calculating total sales for January based on sales till date. But i want to see data for January only on Feb 1. Till then it should not calculate total sales for January. Please let me know if this can be acheived

@unnipbi123 TRy this:

Measure =
VAR cal_ = CALCULATE(SUM('Table'[Sales]),DATEADD(STARTOFMONTH('Table'[Date]),1,MONTH))
RETURN IF(MONTH(MAX('Table'[Date]))<MONTH(TODAY()),BLANK(),cal_)
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Tahreem24
Super User
Super User

@unnipbi123 Create a measure like below:

Measure = CALCULATE(SUM('Table'[Sales]),DATEADD(STARTOFMONTH('Table'[Date]),1,MONTH))
Capture.PNG
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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.