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
Anonymous
Not applicable

get last 6 months last day value

Hi All, @Anonymous @Anonymous @Greg_Deckler @amitchandak @nandic 

Need you help with a DAX formula .

I would need to derive the last 6 months AGO last day sales . Please note the requirement is to get data for  last date of 6 month ago  and not for the entire 6 months from selected date. E.g. if today is Dec 31 2020 , then i would need to get data for 30 jun 2020 (last non blank value of month of Jun 2020) and compare against Dec 31 2020.

i do have a calendar table which has month offset but am not able to get it working . 

i have used DATEADD FUNCTION = DATEADD(CALENDAR[EOM],-6,MONTH) but this works for some months and not for others .

appreciate your help . 

i have tried the below as well , but this dosen't seem to work for some of th emonths 

var last6month = values('Calendar'[last6month]) // this is a custom column created in calendar table to get last date of 6 month ago 
Var SALES6Mago =
SUMX(FILTER(ALL('Calendar'),'Calendar'[Date]=lastmonth),[Total SALES])

here is a sample data :

 

DateProductPrice
29 Jun 2020A1
29 Jun 2020B2
30 Jun 2020A3
30 Jun 2020B4
30 Dec 2020A5
30 Dec 2020B6
31 Dec 2020A7
31 Dec 2020B8

 

Expected Result is 

Today = 31 Dec 2020 = SUMX(7+8) = 15
last 6 month ago = 30 JUn = SUMX(3+4) = 7 
Thanks in advance

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , you time intelligence with 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]))

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

6 Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-6,Month))

 

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

View solution in original post

5 REPLIES 5
Tahreem24
Super User
Super User

@Anonymous  - You can calculate last day of 6 month ago price with below measure:

Latest 6 Month Price  = CALCULATE(SUM(TableA[Price]),DATEADD(ENDOFMONTH(TableA[FinalDate]),-6,MONTH))
 
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
Anonymous
Not applicable

Hi,

have you tryed the function: EOMONTH(date, -6) ?

Anonymous
Not applicable

Sorry @Anonymous  this dosen't work, it goes back 6 days from last month date 

Anonymous
Not applicable

Thanks @amitchandak  i have tried this formulas but these (DateADD) doesn't work . THanks for your help . finally i ended up crearting last 6 months , last 12 months date based on calendar date and this seems to be working . 

amitchandak
Super User
Super User

@Anonymous , you time intelligence with 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]))

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

6 Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-6,Month))

 

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

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.