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

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors