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
allenng
Regular Visitor

Create two average lines in one graph chart

good day guys. i am struggling to have two average lines in a graph and it should be dynamic.

 

The average figure should be calculated based on same year. When i tick both years, the average line calculated as total cost frm 2020 to 2021 and divided by 24 mths. I wanted to have separate average lines.

Eg: Average 2020 (calculated based on total cost of 2020 and divided by 12 mths)

      Average 2021 (calculated based on total cost of 2021 and divided by 12 mths)

 

allenng_1-1647413251228.png

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@allenng , if you are using staked line visual you need to two measures

 

you can have measure like

 

//Only year vs Year, not a level below

This Year = CALCULATE([Avg Measure],filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE([Avg Measure],filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

Dear @amitchandak 

Thanks for the reply. My data is quite basic and straightforward.

I was thinking to use line and clustered column chart. However, if i select default Average Total Cost, the line is kind of weird (2nd photo). i am wishing to have something like 3rd photo, showing 2 dotted average lines.

i am a beginner for this pbi and not familiar with DAX. Thanks to guide and advise.

 

allenng_0-1647935107922.png

 

below is line & clustered column chart

allenng_1-1647935239911.png

 

allenng_2-1647935384295.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.