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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Measure - if no data -> take last available data to calculate average

Hello All!

 

I have time and again used information in this forum to solve my many problems with PowerBi but can't seem to find a solution this time, so I'm hoping you guys can help me.

I am working on a report that gives me average prices for products purchased. Say I have a product - bananas - which I bought 4 times in the month of January, twice in February and once in May.  So my data looks like this:

 

ProductMonthUnit Price
BananasJanuary15
BananasJanuary18
BananasJanuary11
BananasJanuary13
BananasFebruary12
BananasFebruary9
BananasMay

8

 

What I need is a matrix and a chart that would tell me the average price for Bananas per month. So January = 14,25, February = 10,50, May= 8  - that I have no problem with. The problem is with months like March and April. To ensure continutity of data, I would like PowerBi to recognize there is no unit price data for March and April and if that happens, take the last data/last average that is available (February in this case). So my final averages table would like like this:

 

Average Price per monthJanuaryFebruaryMarchAprilMay
Bananas14,2510,5010,510,58

 

I've tried several combinations to achieve this but can't get the right result 😞

 

Can provide example pbix if needed. 

Thanks!

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Please check the solution by @mh2587 First, if that can solve. But I doubt simple Avg will work here

 

You prefer have Date/Month/Year month table with one column as sortable year month or Month (YYYYMM or MM)

 

Then you can have formula like

calculate(lastnonblankvalue(Date[Year Month], Average(Table[Unit Price])), filter( all('Date'), 'Date'[Date] <= max('Date'[Date])))

 

In filter in place date you can use year month( YYYYMM) or  month (MM)

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

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Please check the solution by @mh2587 First, if that can solve. But I doubt simple Avg will work here

 

You prefer have Date/Month/Year month table with one column as sortable year month or Month (YYYYMM or MM)

 

Then you can have formula like

calculate(lastnonblankvalue(Date[Year Month], Average(Table[Unit Price])), filter( all('Date'), 'Date'[Date] <= max('Date'[Date])))

 

In filter in place date you can use year month( YYYYMM) or  month (MM)

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

@amitchandak Sorry for a late reply but I played around with it a bit and your suggestions was of tremendous help. The formula finally works like I wanted it to. Big High Five for you Sir! Thanks 😊

mh2587
Super User
Super User

Measure = AVERAGE('Table'[Unit Price])

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Anonymous
Not applicable

Thanks but as I said that's not the issue I'm struggling with

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors