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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Samarth-Borade
Frequent Visitor

Get average of Outstanding for last 3 months excluding the selected month .

I have a table Contract No , in power bi , now in that i have columns "Month" , which is just the month number , "Outstanding" , so in "Month" slicer if i select one month for example 10 that is October , then i want the Average of Outstanding of last three months excluding October , so here it will be Outstanding of (July + August + September)/3 . Write a Dax measure for this.

Measure:

Average_3 =
VAR PreviousMonth1 = SELECTEDVALUE('Contract No'[Month]) - 1
VAR PreviousMonth2 = SELECTEDVALUE('Contract No'[Month]) - 2
VAR PreviousMonth3 = SELECTEDVALUE('Contract No'[Month]) - 3
RETURN
(
CALCULATE(
SUM('Contract No'[Outstanding]),
'Contract No'[Month] = PreviousMonth1
) +
CALCULATE(
SUM('Contract No'[Outstanding]),
'Contract No'[Month] = PreviousMonth2
) +
CALCULATE(
SUM('Contract No'[Outstanding]),
'Contract No'[Month] = PreviousMonth3
)
) / 3


When i drag this in a Card it shows Blank , even though there is data it shows Blank .

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Samarth-Borade ,make sure you use date table in such cases

try like

Rolling 3 before current = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],eomonth(MAX('Date'[Date]),-1) ,-3,MONTH))

 

Rolling 3  before current = CALCULATE([Net], WINDOW(-4,REL, -1, REL, ADDCOLUMNS(ALLSELECTED('Date'[Month Year],'Date'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))

 

Running Total/ Cumulative:
https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=42

 

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

 

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.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Samarth-Borade ,make sure you use date table in such cases

try like

Rolling 3 before current = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],eomonth(MAX('Date'[Date]),-1) ,-3,MONTH))

 

Rolling 3  before current = CALCULATE([Net], WINDOW(-4,REL, -1, REL, ADDCOLUMNS(ALLSELECTED('Date'[Month Year],'Date'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))

 

Running Total/ Cumulative:
https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=42

 

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

 

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.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.