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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Issue with Time Intelligence Functions

Hi Guys

 

I am trying to work on this data set where I need to calculate 3 month rolling average of amount invoiced by a doctor (referred to as Doctor 1 below). Each doctor provides multiple services each day and hence every date is repeated multiple times (ranging 2-6).

 

So when I calculate 3 mth rolling average, it divides the average amount by total number of dates (rather than distinct dates). Would really appreciate your help. My DAX is: 

 
Rolling Avg 3 Months =
CALCULATE(AVERAGE(Rad_Reporting[Invoice Total]), DATESINPERIOD(Dim_Date[Date], LASTDATE(Dim_Date[Date]), -3, MONTH))

 

The dates in 'Datesinperiod' come from date table.

 

Source Data:

RadiologistDate Service Invoice Total Report Count
 Doctor 11/07/2019 Consultations751
 Doctor 11/07/2019 CT8,29916
 Doctor 11/07/2019 MRI6,59817
 Doctor 11/07/2019 Screening9902
 Doctor 11/07/2019 Ultrasound3,34415
 Doctor 11/07/2019 X-Ray4748
 Doctor 12/07/2019 CT3,4248
 Doctor 12/07/2019 MRI6,02314
 Doctor 12/07/2019 Screening2501
 Doctor 12/07/2019 Ultrasound2,3397
 Doctor 12/07/2019 X-Ray3164
 Doctor 13/07/2019 CT2,8827
 Doctor 13/07/2019 MRI10,44624
 Doctor 13/07/2019 Screening4951
 Doctor 13/07/2019 Ultrasound1,9566
 Doctor 13/07/2019 X-Ray2383
 Doctor 17/07/2019 CT4511
 Doctor 17/07/2019 MRI13,22433

 

Thanks in advance.

 

Kind regards

Nick Singh

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Not very sure. If you need monthly avg divide by month or by distinct date

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-3,MONTH))
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date]),-3,MONTH))

 

Rolling dates = CALCULATE(Distinctcount(Sales[Sales date]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-3,MONTH))
Rolling dates = CALCULATE(Distinctcount(Sales[Sales date]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date]),-3,MONTH))

 

as distinct count do take calculation then try with the month

Sales Month = eomonth([Sales date],0)

 

Rolling dates = CALCULATE(Distinctcount(Sales[Sales date]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-3,MONTH))
Rolling dates = CALCULATE(Distinctcount(Sales[Sales date]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date]),-3,MONTH))

 

 

Anonymous
Not applicable

Thanks @amitchanda, your formulas helped shape my thinking in getting the desired result.

Greg_Deckler
Super User
Super User

@Anonymous You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors