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
Jeevan1991
Helper III
Helper III

Current Month vs Previous Month

Dear Friends,

 

Please help me on below query in Power BI.

 

I have a date wise outlet sale table like the below.

DateOutletSales
30-Nov-202012435452233243
29-Nov-202012435452443432
30-Nov-202053435454665476
29-Nov-202053435454545344
28-Nov-202053435454423534
30-Oct-202012435452532534
29-Oct-202012435452545346
28-Oct-202012435452564577
30-Oct-202053435454676568
29-Oct-202053435454967567

 

Now i want to create a summary like the below in power bi.

OutletCurrent Month SalesCurrent Month Working DaysCurrent Month ASPD Previous Month SalesPrevious Month Working DaysPrevious Month ASPD
12435452              676,675                2   338,338          1,642,457                3   547,486
53435454           1,210,820                3   403,607          1,644,135                2   822,068

 

Current Month is "Nov 2020" & Previous Month is "Oct 2020".

Total Sales = Total Sales column based on Current Month & Previous Month.

 

Working Days = Distinct Count of Date column based on Current Month & Previous Month.

ASPD (Avg Sale Per Day) = Total Sales /Working Days.

 

@v-easonf-msft @speedramps

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Jeevan1991 , refer if this file I have used these formula's

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@Jeevan1991 , refer if this file I have used these formula's

Hi Amit,

 

This file help me in several other calcualtions, thank you so much.

 

I will try permotations and combinations.

amitchandak
Super User
Super User

@Jeevan1991 , it should work outlet wise, What is the issue you have facing?

Hi Amit,

 

I have used below measure to find Previous Month Total.

 

Net Sales = SUM(Daily_Outlet_Summary[Saeles])

 

Previous Month Sales = 

                       PM_SALES = Var CM = MONTH(TODAY())

                            Return
        CALCULATE([Net Sales],FILTER(Daily_Outlet_Summary,MONTH(Daily_Outlet_Summary[DATE])=CM-1))
 
My worry here is Previous Month total changes dynamically or not using above measures.
amitchandak
Super User
Super User

@Jeevan1991 , With help of time intelligence and date table

 

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
this month =MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH('Date'[Date])))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value =  CALCULATE(sum('Table'[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

 

 

You can these columns for work day

 

Work Day = if(WEEKDAY([Date],2)>=6,0,1)
Work Date = if(WEEKDAY([Date],2)>=6,BLANK(),[Date])
Work Date Cont = if([Work Day]=0,maxx(FILTER('Date',[Date]<EARLIER([Date]) && [Work Day]<> EARLIER([Work Day]) ),[Date]),[Date])
Work Date cont Rank = RANKX(ALL('Date'),[Work Date Cont],,ASC,Dense)

 

 

Working day count

 

 

MTD Sales = CALCULATE(SUM('Date'[Work Day]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM('Date'[Work Day]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

 

 

till work day this month vs last month

Month Work day= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank]) && 'Date'[Work day of month]  <= Max('Date'[Work day of month]) ))
last Month Work day= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1  && 'Date'[Work day of month]  <= Max('Date'[Work day of month]) ))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Hi Amit,

 

Thanks for the quick reply.

 

PREVIOUSMONTH work for dates only i think, but i need outletwise difference. If you could post a screnshot of outletwise table then it will be very useful.

TomMartens
Super User
Super User

Hey @Jeevan1991 ,

 

This article by @GilbertQ describes how you can create a "period table": Create Dynamic Periods for Fiscal or Calendar Dates in Power BI - Reporting/Analytics Made easy with...

 

This table allows to have "columns" like "current month" or "previous month" that can be used as slicer content or as column header inside a matrix visual, nested with measures like sales, working days, ...

 

Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.