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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
xlitol
Frequent Visitor

DAX to write average line of teams by month

 

Hi there ! -  a quick qn. i have the below table which i am using a "line chart" to plot the trend line. X-axis the is YYYY-MM column, and Y-AXIS is SUM(WARNINGS), and legend is TEAM. So basically a trend of total warnings of each team by month. 

I would like a DAX to create a average trending line by month (i.e. no horizontal but an average of total warning by month). What is a quick DAX code to use ?

 

TeamStaff_IDWarningsyyyy-mm
A11112023-01
A11112023-01
A12222023-01
A12212023-02
B21112023-01
B21152023-02
B21132023-04
C31112023-01
C32232023-02
2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

Jihwan_Kim_0-1683167111773.png

 

Jihwan_Kim_1-1683167371021.png

 

Warnings avg: =
VAR _maxdatefacttable =
    CALCULATE ( MAX ( Data[yyyy-mm] ), REMOVEFILTERS ( 'Calendar' ) )
RETURN
    IF (
        MAX ( 'Calendar'[Year-Month sort] ) <= EOMONTH ( _maxdatefacttable, 0 ),
        AVERAGE ( Data[Warnings] ) + 0
    )

 

 


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

Ritaf1983
Super User
Super User

Hi @xlitol 

If I understand you correctly, and the desired result is like in picture

Ritaf1983_0-1683169133237.png

The dax is :

MonthAverage = AVERAGEX(values('Table'[Month]),SUM('Table'[Warnings])/DISTINCTCOUNT('Table'[Team]))
But you'll need to make a separate measure for each line of each team
Here's an example:
WarningsA = CALCULATE(sum('Table'[Warnings]),'Table'[Team]="a")
Link To Sample File 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

2 REPLIES 2
Ritaf1983
Super User
Super User

Hi @xlitol 

If I understand you correctly, and the desired result is like in picture

Ritaf1983_0-1683169133237.png

The dax is :

MonthAverage = AVERAGEX(values('Table'[Month]),SUM('Table'[Warnings])/DISTINCTCOUNT('Table'[Team]))
But you'll need to make a separate measure for each line of each team
Here's an example:
WarningsA = CALCULATE(sum('Table'[Warnings]),'Table'[Team]="a")
Link To Sample File 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

Jihwan_Kim_0-1683167111773.png

 

Jihwan_Kim_1-1683167371021.png

 

Warnings avg: =
VAR _maxdatefacttable =
    CALCULATE ( MAX ( Data[yyyy-mm] ), REMOVEFILTERS ( 'Calendar' ) )
RETURN
    IF (
        MAX ( 'Calendar'[Year-Month sort] ) <= EOMONTH ( _maxdatefacttable, 0 ),
        AVERAGE ( Data[Warnings] ) + 0
    )

 

 


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.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors