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
atrpbiuser
Frequent Visitor

Financial Calculations

Hi -

Trying to replicate a Tableau report to PBI and need some direction.

We have a Sales_Date column inside the main SQL query through which we are trying to pull sales for different periods , however it didn't work out so built a static date table which is joined to the main table as One to Many and now the basic period's calculations like MTD,YTD, LY_MTD,LY_YTD are working fine using time intelligence functions. However we are struggling with 2 calculations "Sales Full Year LY" and "Sales Full Month LY" .

For example sales through 8/25/21 works fine with DATESMTD() although couldn't get to find a function to pull "Sales Full Month LY" which will show sales for entire August Month from last year even though the August month is not complete yet which is why couldn't use SAMEPERIODLASTYEAR() . Any help will be greatly appreciated. 

Thank You.

1 ACCEPTED SOLUTION

Following worked out. 

Sales_Full_Month_LY = CALCULATE(SUM(sheet[INVOICE_SALES]),DATESMTD(ENDOFMONTH(DATEADD(Calender_Dates[Inv_Dates],-12,MONTH))))

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@atrpbiuser , use previousmonth and previousyear

 

 

last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

last MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))

 

last Year Sales = CALCULATE(SUM(Sales[Sales Amount]),previousyear('Date'[Date]))

 

Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))

 


This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

Thank you very much @amitchandak -

 

Will last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))  return full month's sale from last year ?

 

For example - today is 8/30/21 and still has one day to close the month , what we are looking to display is last year August's full month sales from 8/1/2020-8/31/2020 alongside the current MTD (8/1/2021-8/30/2021) sales .

 

Thank you very much for your assistance. 

 

Following worked out. 

Sales_Full_Month_LY = CALCULATE(SUM(sheet[INVOICE_SALES]),DATESMTD(ENDOFMONTH(DATEADD(Calender_Dates[Inv_Dates],-12,MONTH))))

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.