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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Line chart - Dynamic Average Line

Hello, I need som help making a dynamic line chart. The chart is used to compare an indivudual employee working hours with the average working hours for all the employees. 

 

Here is a portion of the data input:

1.png

 

Here is the Power Bi page:

2.png


The field input for the slicer in the top left is the column "ID and NAME". The input for the linechart in the top right is a measure I created: Total # of Hours = CALCULATE(SUM('Export Worksheet'[HOURS]))

 

To create an average line I made two new measures:

Total # of Employees = DISTINCTCOUNT('Export Worksheet'[EMPLOYEE NO])

Average = CALCULATE(DIVIDE([Total # of Hours];[Total # of Employees]))

 

I then added this new measure to the line chart. However since the linechart interacts with the ID and NAME slicer the "Average" line allways coincides with the selected employee, Like this:

3.png

 

 

 To try to fix this I modified my measure and added the bold text:

Average = CALCULATE(DIVIDE([Total # of Hours];[Total # of Employees]);ALLEXCEPT('Export Worksheet';'Export Worksheet'[EMPLOYEE NO]))

 

This just created a straight line for the whole year, like this:

3.5.png

 

I then modified the measure again by adding the following bold text:

Average = CALCULATE(DIVIDE([Total # of Hours];[Total # of Employees]);ALLEXCEPT('Export Worksheet';'Export Worksheet'[EMPLOYEE NO];'Export Worksheet'[START DATE].[Month]))

Now it looked like this:

4.png

 

 

This got the results I wanted however the the "Average" line is static and does not interact with the time slicer. Using the slicer only affects individual employee line, like this:

5.png

So the question is, how can I make a dynamic average line?

 

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please update your measure as below.

Average = 
CALCULATE (
    DIVIDE ( [Total # of Hours], [Total # of Employees] ),
    ALLSELECTED ( 'Export Worksheet' ),
    VALUES ( 'Export Worksheet'[EMPLOYEE NO] ),
    VALUES ( 'Export Worksheet'[START DATE].[Month] )
)

 

Capture.PNG

 

Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hello! @v-frfei-msft 

 

Thanks for replaying to my post. 
I cant get the pbix file you attached working as I want.

This is what Im looking for:

1.png

 

However I a select employee "A" for example this happens:

2.png

The "Average line" no longer shows the Average working hours but shows the working hours for the selected employee so the two lines coincide. This means a cannot compare the "selected employee" with the "average employee"

 

Hopefully this picture can explain better what Im looking for:

3.png

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.