Power BI中按生效年份统计Rater/Walkaway工具占比的带百分比卡片条形图实现方法
Alright, let's walk through exactly how to build this report—assuming you're using Power BI (the go-to tool for slicer-driven visualizations like this). Here's a step-by-step breakdown:
First, make sure your table is loaded correctly with the right data types:
- 唯一提交编号: Set to integer/text (ensure no duplicates, since this is your unique ID)
- Tool Indicator: Text type (values: Yes/No)
- Tool Type: Text type (values: Rater/Walkaway/Null)
- Effective year: Integer/date type (so the year slicer works smoothly)
You'll need 3 core measures to calculate percentages that update with your year slicer selection:
Total Submissions
Total Submissions = DISTINCTCOUNT('Your Table Name'[唯一提交编号])
Why DISTINCTCOUNT? It ensures each unique submission is counted only once, even if there are accidental duplicates in your data.
Rater Tool Percentage
Rater % = VAR RaterSubmissions = CALCULATE(DISTINCTCOUNT('Your Table Name'[唯一提交编号]), 'Your Table Name'[Tool Type] = "Rater") VAR Total = [Total Submissions] RETURN DIVIDE(RaterSubmissions, Total, 0)
This measure filters for only Rater-associated submissions, then divides by total submissions. DIVIDE avoids errors if total submissions are zero.
Walkaway Tool Percentage
Walkaway % = VAR WalkawaySubmissions = CALCULATE(DISTINCTCOUNT('Your Table Name'[唯一提交编号]), 'Your Table Name'[Tool Type] = "Walkaway") VAR Total = [Total Submissions] RETURN DIVIDE(WalkawaySubmissions, Total, 0)
Same logic as the Rater measure—just filters for Walkaway instead.
- Drag
Effective yearonto your canvas, select the Slicer visual, and set it to your preferred selection mode (single-select, dropdown, etc.). - Optional: Add
Tool IndicatorandTool Typeslicers if you want extra filtering control. By default, slicers will automatically filter all visuals on the page.
You have two solid options here, depending on your preferred layout:
Option 1: Bar Chart + Separate Percentage Cards
Build the Bar Chart:
- Drag
Tool Typeto the Axis (right-click it > Filter to exclude Null values, so only Rater/Walkaway show up) - Drag both
Rater %andWalkaway %to the Values field. Switch to a Clustered Bar Chart for clear side-by-side comparison. - Format the Y-axis to show percentages (go to Format > Y-axis > Display units > Percentage)
- Drag
Add Percentage Cards:
- Drag
Rater %andWalkaway %onto the canvas as separate Card visuals. - Format each card to display percentages (go to Format > Data label > Display units > Percentage, and adjust decimal places as needed)
- Position the cards above or next to the bar chart—they’ll automatically update when you select a year in the slicer.
- Drag
Option 2: Bar Chart with Inline Percentage Labels
If you don’t want separate cards, you can embed percentages directly on the bars:
- Create the bar chart as described in Option 1.
- Go to Format > Data labels and toggle them on.
- Set the label value to Value (your percentage measures) and format it to show percentages.
- Optional: Add a single card for
Total Submissionsto give context to the percentages.
Double-check that your slicers are filtering all visuals:
- Click the
Effective yearslicer, then go to Format > Edit interactions - Ensure the bar chart and cards have the Filter icon enabled (not the None icon)
If you’re using a different tool like Tableau, the core logic is the same: create calculated fields for the percentages, set up a year filter, and build your visuals. Power BI is just the most common tool for this use case.
内容的提问来源于stack exchange,提问作者katy89

