Power BI Practice: Creating a Median Salary Reference Line in Power BI Clustered Bar Chart
Scenario:
You have a clustered bar chart that contains a measure named Salary as the value and a field named Employee as the axis. Salary is present in the data as numerical amount representing US dollars. You need to create a reference line to show which employees are above the median salary.
Solution: You create a percentile line by using the Salary measure and set the percentile to 50%. Does this meet the goal?
Answer: Yes, this solution meets the goal. By creating a percentile line and setting it to the 50th percentile (median), you effectively create a reference line that shows which employees have salaries above the median. This allows you to visually identify employees whose salaries are above the median salary on the clustered bar chart.
Here are the step-by-step instructions to create a reference line at the median salary in a clustered bar chart in Power BI:
Step-by-Step Guide
[1] Load Your Data:
• Ensure your data, including the Salary measure and Employee field, is loaded into Power BI.
[2] Create the Clustered Bar Chart:
• Go to the Visualizations pane.
• Select the Clustered Bar Chart icon.
• Drag the Employee field to the Axis area.
• Drag the Salary measure to the Values area.
[3] Add a Percentile Line:
• Click on the clustered bar chart to select it.
• In the Visualizations pane, click on the Analytics icon (looks like a magnifying glass).
• Under Percentile Line, click on Add.
• Set the Percentile to 50% to represent the median.
• You can customize the line's color, style, and label as needed.
[4] (Optional) Create a measure to calculate media for checking purpose.
• Go to the "Modeling" tab on the ribbon. Click on "New Measure".
• Enter the following DAX formula to create a measure for the median salary:
Median Salary = MEDIAN('employee'[Salary])
[5] Review and Save:
• Review the chart to ensure the reference line is correctly placed at the median salary.
• Save your Power BI report.
By following these steps, you should be able to create a reference line at the median salary in your clustered bar chart, helping you identify which employees are above the median salary.
Sample Data Table
Here's a sample table you can use to practice creating a reference line at the median salary in a clustered bar chart:
Employee ID | Employee Name | Salary (USD) |
1 | Alice | 70,000 |
2 | Bob | 55,000 |
3 | Charlie | 60,000 |
4 | David | 80,000 |
5 | Eve | 75,000 |
6 | Frank | 65,000 |
7 | Grace | 90,000 |
8 | Hannah | 50,000 |
9 | Ian | 85,000 |
10 | Jane | 95,000 |
You can save this table as an Excel file and use it to practice the steps for adding a percentile line in Power BI.