月度销售同比对比表新增行计算并展示百分比变化需求
Alright, let's work through this step by step to get that percentage change row added to your sales table. First, let's lock in the data we're using (I'll go with the corrected Mar-18 values from your expected output):
Original Sales Data
| Month_Year | Sale_Vol | #Sales | Average_Price |
|---|---|---|---|
| Mar-17 | 1250 | 25 | 50 |
| Mar-18 | 900 | 15 | 60 |
Calculating Each Metric's YoY Change
Using your specified formula ((Current Year Value / Previous Year Value) - 1) * 100, here's how we get each percentage:
- Sale_Vol:
((900 / 1250) - 1) * 100 = -28%(a 28% drop in sales volume) - #Sales:
((15 / 25) - 1) * 100 = -40%(a 40% decrease in total sales transactions) - Average_Price:
((60 / 50) - 1) * 100 = +20%(a 20% increase in average price per sale)
Final Table with YoY Percentage Change
| Month_Year | Sale_Vol | #Sales | Average_Price |
|---|---|---|---|
| Mar-17 | 1250 | 25 | 50 |
| Mar-18 | 900 | 15 | 60 |
| YoY % Change (18 vs 17) | -28% | -40% | +20% |
If you need to automate this for monthly updates (since your table swaps in new period data regularly), you can set up dynamic formulas in your tool of choice. For example, in Excel/Google Sheets, you could use =(B3/B2-1)*100 for the Sale_Vol change and drag it across the row—just make sure the formula references the correct previous-year row each month.
内容的提问来源于stack exchange,提问作者ravsun

