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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Pier2
Resolver I
Resolver I

Calculate average but ignoring when only one row

Hello,

I do calculate an average for a period of time based on

Pier2_0-1719667665421.png

I want to stop calculating an average when only one value is available, which is usually the first year of the period because there's nothing before.

Exemple

YearValuesActual Mean returnedReal Mean wished
20141818 
2015201919
2016624141
20173548,548,5



I've try different approches and it simply move foward the problem in the period.

Any idea?

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @Pier2 ,

You can achive your required output in many different ways and one of them is creating a calculated column as follows:

Previous year =
VAR PY =
    CALCULATE (
        SUM ( 'Table'[Values] ),
        FILTER ( 'Table', 'Table'[year] = EARLIER ( 'Table'[Year] ) - 1 )
    )
VAR CY =
    CALCULATE ( SUM ( 'Table'[Values] ) )
RETURN
    IF ( PY = BLANK (), BLANK (), ( PY + CY ) / 2 )

 

 

DataNinja777_0-1719671759300.png

I attach an example pbix file.  

 

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Assuming you have a measure by the name of [Actual in previous year], write this measure

Measure = if(isblank([actual in previous year]),blank(),averagex(summarize(calculatetable(calendar,previousyear(calendar[date])),calendar[year],"A",[amount]),[A]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
DataNinja777
Super User
Super User

Hi @Pier2 ,

You can achive your required output in many different ways and one of them is creating a calculated column as follows:

Previous year =
VAR PY =
    CALCULATE (
        SUM ( 'Table'[Values] ),
        FILTER ( 'Table', 'Table'[year] = EARLIER ( 'Table'[Year] ) - 1 )
    )
VAR CY =
    CALCULATE ( SUM ( 'Table'[Values] ) )
RETURN
    IF ( PY = BLANK (), BLANK (), ( PY + CY ) / 2 )

 

 

DataNinja777_0-1719671759300.png

I attach an example pbix file.  

 

Thanks you for your help @Ashish_Mathur  and @DataNinja777 . Problem solved.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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