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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
austena229022
Frequent Visitor

Average Line per Month

I am creating a graph of the applications that have been received each month for the past 3 years.

 

What I ma needing to do is to create a 2 year average line that would show an estimated average from the past 2 years by month - eg: June average for the past 2 years is 1.2k, July average is 3.5k etc to be plotted on the graph

 

Would anyone know how to do this?

austena229022_0-1738717484542.png

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_1-1738728396161.png

 

 

Jihwan_Kim_0-1738728324183.png

 

Sales measure: = 
SUM( sales[sales] )

 

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

 

rolling 24 months avg sales measure: = 
VAR _t =
    WINDOW (
        -24,
        REL,
        -1,
        REL,
        ALL ( 'calendar'[Month Year], 'calendar'[Month Year sort] ),
        ORDERBY ( 'calendar'[Month Year sort], ASC )
    )
RETURN
    IF (
        COUNTROWS ( _t ) = 24
            && SUM ( sales[sales] ),
        AVERAGEX (
            WINDOW (
                -24,
                REL,
                -1,
                REL,
                ALL ( 'calendar'[Month Year], 'calendar'[Month Year sort] ),
                ORDERBY ( 'calendar'[Month Year sort], ASC )
            ),
            CALCULATE ( SUM ( sales[sales] ) )
        )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @austena229022 ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Jihwan_Kim_1-1738728396161.png

 

 

Jihwan_Kim_0-1738728324183.png

 

Sales measure: = 
SUM( sales[sales] )

 

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

 

rolling 24 months avg sales measure: = 
VAR _t =
    WINDOW (
        -24,
        REL,
        -1,
        REL,
        ALL ( 'calendar'[Month Year], 'calendar'[Month Year sort] ),
        ORDERBY ( 'calendar'[Month Year sort], ASC )
    )
RETURN
    IF (
        COUNTROWS ( _t ) = 24
            && SUM ( sales[sales] ),
        AVERAGEX (
            WINDOW (
                -24,
                REL,
                -1,
                REL,
                ALL ( 'calendar'[Month Year], 'calendar'[Month Year sort] ),
                ORDERBY ( 'calendar'[Month Year sort], ASC )
            ),
            CALCULATE ( SUM ( sales[sales] ) )
        )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

This is great thank you, it worked when using the COUNTROWS function instead of SUM

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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