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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
MK85
Frequent Visitor

12 month Avg constant line on 13 month bar chart

Hi, 
I am looking for a DAX measure which can show me 12 month avg for previous 12 months as a constant line on bar chart. As shown below.

MK85_1-1715271210538.png

Thanks in advance

 

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

Hi @MK85 ,

 

Thanks for the reply from @Greg_Deckler .

 

First, create a disconnected date table:

Date = VALUES('Table'[Date])

 

Apply this disconnected table as a slicer.

 

Create a measure:

12-Month Average =
CALCULATE(
     AVERAGE('Table'[Value]),
     DATESINPERIOD('Table'[Date], SELECTEDVALUE('Date'[Date]), -12, MONTH)
)

 

Set up the chart as follows:

vhuijieymsft_0-1715333312749.png

vhuijieymsft_1-1715333312749.png

 

The final page effect is as follows:

vhuijieymsft_2-1715333322749.png

vhuijieymsft_3-1715333322753.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
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!

View solution in original post

4 REPLIES 4
v-huijiey-msft
Community Support
Community Support

Hi @MK85 ,

 

Thanks for the reply from @Greg_Deckler .

 

First, create a disconnected date table:

Date = VALUES('Table'[Date])

 

Apply this disconnected table as a slicer.

 

Create a measure:

12-Month Average =
CALCULATE(
     AVERAGE('Table'[Value]),
     DATESINPERIOD('Table'[Date], SELECTEDVALUE('Date'[Date]), -12, MONTH)
)

 

Set up the chart as follows:

vhuijieymsft_0-1715333312749.png

vhuijieymsft_1-1715333312749.png

 

The final page effect is as follows:

vhuijieymsft_2-1715333322749.png

vhuijieymsft_3-1715333322753.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
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!

It works. Many thanks @v-huijiey-msft 

Greg_Deckler
Super User
Super User

@MK85 (3) Better Rolling Average - Microsoft Fabric Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

It doesn't work for as I have dates on x-axis from date table and my context is changing every month, which gives me variable avg for each month.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.