Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext 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
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:
Here is the Power Bi page:
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:
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:
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:
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:
So the question is, how can I make a dynamic average line?
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] )
)
Pbix as attached.
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:
However I a select employee "A" for example this happens:
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:
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 47 | |
| 44 | |
| 40 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 70 | |
| 68 | |
| 32 | |
| 27 | |
| 25 |