Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
comacabana
Frequent Visitor

Percentage change between last month and two months ago

Hi all,

 

I'm having some issues with time intelligence formulas. I'm trying to find the percent difference between a value of last month and two months ago. My current model is connected live to sqlsas so I have no control over the tables. The date table doesn't have a hierarchy and I was told this was done purposefully due to complications which I cannot remember. I'm wondering if what I want to achieve can't be done because of this.

The current measure I have for the overall average of a datediff function is 

AVERAGEX(FactRS,DATEDIFF(FactRS[CaseCreatedDate], MAXX(RELATEDTABLE(FactSC), FactSc[CreatedDate]), HOUR))

 

How would I go about finding the percentage change? I've tried various versions of the below formula to see if I can even see the average datediff of two months ago with no success

AVERAGEX(FILTER(FactRs, MONTH(TODAY())-2), DATEDIFF(FRs[CaseCreatedDate], MAXX(RELATEDTABLE(FactSC), FactSc[CreatedDate]), HOUR))

 

Thank you  for your help!

1 REPLY 1
amitchandak
Super User
Super User

@comacabana , make sure you have column without a timestamp to join with date table

 

Date = datevalue(FactRS[CaseCreatedDate])

 

Join the date with date of date table and then you can have measure like

 

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

2nd last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-2,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

 

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

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

 

based on today, no slicer of filter on date

 

This Month Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),0)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Last Month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

2nd Last Month Today =
var _min = eomonth(today(),-3)+1
var _max = eomonth(today(),-2)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
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.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.