cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Reddy5833
Helper I
Helper I

How to fill the missing values with the average of previous values by category and by fiscal year.

Hi,

I have a requirement to fill the missing values of the months with the average of previous months with in fiscal year, 

 

Reddy5833_2-1659534875226.png

Note: My fiscal year starts from Oct so the average should be calculated form oct of that year.

Can some one help me to achieve this. Thanks in advance.

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @Reddy5833 ,

 

Please create two calculated columns:

Year = 
VAR _start_of_year =
    STARTOFYEAR ( 'Date'[Date], "9/30" )
VAR _fin_year =
    YEAR ( _start_of_year )
RETURN
    _fin_year
Column = 
VAR _avg =
    CALCULATE (
        AVERAGE ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Category] = EARLIER ( 'Table'[Category] )
                && 'Table'[Year] = EARLIER ( 'Table'[Year] )
        )
    )
VAR _fill =
    IF ( 'Table'[Value] <> BLANK (), 'Table'[Value], _avg )
RETURN
    _fill

Result:

vcgaomsft_0-1659930620505.png

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
Reddy5833
Helper I
Helper I

Hi @v-cgao-msft 

Thanks a lot, it is working like a charm.

v-cgao-msft
Community Support
Community Support

Hi @Reddy5833 ,

 

Please create two calculated columns:

Year = 
VAR _start_of_year =
    STARTOFYEAR ( 'Date'[Date], "9/30" )
VAR _fin_year =
    YEAR ( _start_of_year )
RETURN
    _fin_year
Column = 
VAR _avg =
    CALCULATE (
        AVERAGE ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Category] = EARLIER ( 'Table'[Category] )
                && 'Table'[Year] = EARLIER ( 'Table'[Year] )
        )
    )
VAR _fill =
    IF ( 'Table'[Value] <> BLANK (), 'Table'[Value], _avg )
RETURN
    _fill

Result:

vcgaomsft_0-1659930620505.png

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors