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

Average of Last 18 months projected forward?

Hey All,

I'm currently having trouble with a rolling 18 month average. Since I'm a new member and don't yet have the ability to upload a file, a picutre of the data Im using is here: 

data.PNG

Ideally, the measure in PowerBI would take an average of the past 18 months for every month after the given data set, as shown here:

data2.PNG

Currently, the code I have for a measure in PowerBI is here:

currentcode.PNG

The issue here is that it ignores the vales already present, and instead uses averages for the months I already haave values for:
resuklt.PNG

Anything you could do to help would be greatly appreciated, and thanks in advance.

8 REPLIES 8
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

I test it by my simple data ,and you could try it:

AVE 18 =
AVERAGEX (
    FILTER (
        ALL ( 'Date' ),
        [Date] <= EOMONTH ( MAX ( [Date] ), -1 )
            && [Date] > EOMONTH ( MAX ( [Date] ), -19 )
    ),
    [Total]
)

The final output is shown below:

vyalanwumsft_0-1637039339873.pngvyalanwumsft_1-1637039362977.png

If not right,can you tell me the result you want to output in my simple data?Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

So the issue I'm having with this solution is that the averages dont take in the new averages:

issue.PNG

The solution would look more like this.

PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

I'm not following and without seeing your source data it's hard to understand the problem.  All I can see is a summary table, I can't tell what's wrong in it.

 

Can you please supply some raw data and show where the issue is.

 

Thanks

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Instead of using the actual values, this average results in the values for April 2021 - October 2021 to be overwritten with the average, the result I'm looking for should look like this:average.PNG

Where the last 18 months are averaged after the last month in the data and used as the value for Nov 2021 and so on

Hi @Anonymous 

 

It's still not clear.

 

You say Instead of using the actual values - what actual values?

 

Where the last 18 months are averaged after the last month in the data  - do you mean the last month is Dec 2022?

 

Unfortuantely, this still has the same issue, where the averaging begins before the actual values, - what do you mean?  Please show how averaging begins before the actual values.  What values?

 

You say the result you're looking for is in that screenshot.  I can see that the value for Nov 2021 is the average of the months preceeding it.  But why are all the value from Dec 2021 to Oct 2022 the same?  And how are the value sin Nov and Dec 2022 calculated?

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

The actual values are highlighted in this photo, as in they are actual values taken from a dataset that are not calculations.

data2.PNG

Values for the months after these, Nov 2021 onward, need to be an average of the 18 months prior.

PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

Download example PBIX file

 

I've tried to recreate your data in that file but it's probably not exactly correct.

 

However you can use this measure to get the previous 18m rolling average

 

Avg18M = 
   
VAR _Period = DATESINPERIOD( 'DateTable'[Date], MAX( 'DateTable'[Date] ), - 18, MONTH )

VAR _Result = 
        CALCULATE (
            AVERAGEX (
                'DataTable',
                [Avg]
                    ),
            _Period
    )

RETURN _Result

 

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Unfortuantely, this still has the same issue, where the averaging begins before the actual values, so the values are altere for the dates that have data. 

avg18.PNG

DAX used: 

avg.PNG

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.