27.8 Pharma: Stock Value and Near-Expiry Batches
Example first. Ravina controls stock at fictional pharma distribution depots and must flag batches that expire within 90 days.
Pharma project — in 30 seconds
What: A Pharma tracker: one Table tblStock, the calculated column StockValue, KPI cells, a PivotTable by City, a chart and a one-page dashboard.
Why: This is the shape of a real Pharma report: Stock Value, Near-expiry Value, Near-expiry % are the numbers a manager reads first.
Tiny example: From 6 rows: Stock Value = ₹1,81,200, Near-expiry Value = ₹78,600, Near-expiry % = 43.4%.
Pharma project — 30 सेकंदात
काय: Pharma चा tracker: tblStock नावाची एक Table, StockValue हा calculated column, KPI cells, City प्रमाणे PivotTable, एक chart आणि एका पानाचा dashboard.
का: खऱ्या Pharma report चा हाच आकार असतो: Stock Value, Near-expiry Value, Near-expiry % हे आकडे manager सगळ्यात आधी वाचतो.
छोटं उदाहरण: 6 rows मधून Stock Value = ₹1,81,200, Near-expiry Value = ₹78,600, Near-expiry % = 43.4%.
Pharma project — 30 सेकंड में
क्या: Pharma का tracker: tblStock नाम की एक Table, StockValue calculated column, KPI cells, City के हिसाब से PivotTable, एक chart और एक पन्ने का dashboard.
क्यों: असली Pharma report का यही आकार होता है: Stock Value, Near-expiry Value, Near-expiry % वे आँकड़े हैं जो manager सबसे पहले पढ़ता है.
छोटा उदाहरण: 6 rows से Stock Value = ₹1,81,200, Near-expiry Value = ₹78,600, Near-expiry % = 43.4%.
First look at the data (before → after):
Expected result — Calculated columns
| Batch | StockValue | NearExpiry |
|---|---|---|
| B-101 | ₹21,600 | No |
| B-102 | ₹33,600 | Yes |
| B-103 | ₹18,000 | Yes |
| B-104 | ₹57,000 | No |
| B-105 | ₹27,000 | Yes |
| B-106 | ₹24,000 | No |
About this data: Teaching sample for a fictional shop “Maple Bakery Co”. Figures and names (e.g. Sana Sheikh) are made up for this lesson on pharma stock value and near expiry batches.
Expected result — KPI cells (expected results)
| KPI | Formula | Result |
|---|---|---|
| Stock Value | =SUM(tblStock[StockValue]) | ₹1,81,200 |
| Near-expiry Value | =SUMIFS(tblStock[StockValue],tblStock[NearExpiry],"Yes") | ₹78,600 |
| Near-expiry % | =SUMIFS(tblStock[StockValue],tblStock[NearExpiry],"Yes")/SUM(tblStock[StockValue]) | 43.4% |
About this data: Demo table only — not real customer or company data. Built to practise pharma stock value and near expiry batches.
Before table and formula as text
Before — Table tblStock (fictional sample rows)
| Batch | City | Units | UnitCost | ExpiryDays |
|---|---|---|---|---|
| B-101 | Pune | 1,200 | 18 | 240 |
| B-102 | Pune | 800 | 42 | 60 |
| B-103 | Nashik | 1,500 | 12 | 45 |
| B-104 | Nagpur | 600 | 95 | 180 |
| B-105 | Solapur | 900 | 30 | 75 |
| B-106 | Kolhapur | 400 | 60 | 365 |
About this data: Made-up rows so you can copy the pattern for pharma stock value and near expiry batches. Currencies may use ₹, £, € or $.
Formula / click path
StockValue: =[@Units]*[@UnitCost]
NearExpiry: =IF([@ExpiryDays]<=90,"Yes","No")
Stock Value: =SUM(tblStock[StockValue])
Near-expiry Value: =SUMIFS(tblStock[StockValue],tblStock[NearExpiry],"Yes")
Near-expiry %: =SUMIFS(tblStock[StockValue],tblStock[NearExpiry],"Yes")/SUM(tblStock[StockValue])
Do it step by step:
- Type the data and press Ctrl+T; name the Table
tblStockin Table Design › Properties › Table Name. - Add the column StockValue with
=[@Units]*[@UnitCost]; the Table fills it down. Add the other calculated columns from the table below the same way. - On a KPI sheet type
=SUM(tblStock[StockValue])and the other KPI formulas from the table below. - Click Insert › PivotTable › From Table/Range, put City in Rows and StockValue in Values (Sum).
- Click PivotTable Analyze › PivotChart › Clustered Column, then PivotTable Analyze › Insert Slicer › NearExpiry.
- Move the KPI cells, the chart and the slicer onto a sheet named Dashboard.
स्टेप बाय स्टेप करून बघा:
- Data type करा आणि Ctrl+T दाबा; Table Design › Properties › Table Name मध्ये Table ला
tblStockनाव द्या. - StockValue column
=[@Units]*[@UnitCost]ने जोडा; Table तो खाली भरते. खालच्या table मधले बाकीचे calculated columns असेच जोडा. - KPI sheet वर
=SUM(tblStock[StockValue])आणि खालच्या table मधले बाकीचे KPI formulas type करा. - Insert › PivotTable › From Table/Range वर click करा, Rows मध्ये City आणि Values मध्ये StockValue (Sum) ठेवा.
- PivotTable Analyze › PivotChart › Clustered Column वर click करा, मग PivotTable Analyze › Insert Slicer › NearExpiry.
- KPI cells, chart आणि slicer Dashboard नावाच्या sheet वर हलवा.
स्टेप बाय स्टेप करके देखें:
- Data type करें और Ctrl+T दबाएँ; Table Design › Properties › Table Name में Table को
tblStockनाम दें. - StockValue column
=[@Units]*[@UnitCost]से जोड़ें; Table उसे नीचे भर देती है. नीचे की table के बाकी calculated columns भी ऐसे ही जोड़ें. - KPI sheet पर
=SUM(tblStock[StockValue])और नीचे की table के बाकी KPI formulas type करें. - Insert › PivotTable › From Table/Range पर click करें, Rows में City और Values में StockValue (Sum) रखें.
- PivotTable Analyze › PivotChart › Clustered Column पर click करें, फिर PivotTable Analyze › Insert Slicer › NearExpiry.
- KPI cells, chart और slicer को Dashboard नाम की sheet पर ले जाएँ.
The brief. Build a depot stock sheet: stock value per batch, a near-expiry flag (90 days or less), total stock value, near-expiry value and %, stock value by city, a chart and a NearExpiry slicer.
Calculated column formulas:
| Column | Formula |
|---|---|
| StockValue | =[@Units]*[@UnitCost] |
| NearExpiry | =IF([@ExpiryDays]<=90,"Yes","No") |
About this data: Fictional worksheet used in class. Safe to edit; nothing here is live production data.
KPI cells (check your numbers):
| KPI | Formula | Result |
|---|---|---|
| Stock Value | =SUM(tblStock[StockValue]) | ₹1,81,200 |
| Near-expiry Value | =SUMIFS(tblStock[StockValue],tblStock[NearExpiry],"Yes") | ₹78,600 |
| Near-expiry % | =SUMIFS(tblStock[StockValue],tblStock[NearExpiry],"Yes")/SUM(tblStock[StockValue]) | 43.4% |
About this data: Teaching sample for a fictional shop “Maple Bakery Co”. Figures and names (e.g. Sana Sheikh) are made up for this lesson on pharma stock value and near expiry batches.
PivotTable (expected):
| City | Sum of StockValue |
|---|---|
| Kolhapur | ₹24,000 |
| Nagpur | ₹57,000 |
| Nashik | ₹18,000 |
| Pune | ₹55,200 |
| Solapur | ₹27,000 |
| Grand Total | ₹1,81,200 |
About this data: Demo table only — not real customer or company data. Built to practise pharma stock value and near expiry batches.
Chart and dashboard (one under the other):
- Click inside the PivotTable, then PivotTable Analyze › PivotChart › Clustered Column › OK.
- Add a chart title and data labels with Chart Design › Add Chart Element.
- Click PivotTable Analyze › Insert Slicer, tick NearExpiry and click OK.
- Insert a new sheet named Dashboard. In it, link a card cell to each KPI (for example
=KPI!B2) and format it large and bold. - Cut and paste the chart and slicer onto the Dashboard sheet.
- On the View tab, untick Gridlines in the Show group. Select the dashboard area and click Page Layout › Print Area › Set Print Area.
Template and guide: download the practice template Pharma_Template.xlsx and read the step-by-step template guide. The template's sample rows may differ from the rows above; the method is the same.
Related ready-made dashboard: the Pharma dashboard guide and its workbook Pharma_Dashboard.xlsx show a finished version of this kind of report.
Practice task (try it before you open the answer):
- Which city has the highest sum of StockValue?
- Filter the Table on City = Nagpur (Data › Filter): what is Stock Value for Nagpur alone?
- Add the Clustered Column PivotChart and the NearExpiry slicer to your Dashboard sheet.
Answer
Nagpur (₹57,000). For Nagpur only (1 row): Stock Value = ₹57,000. The chart shows 5 bars, one per city.
Ravindra Bagale's Tip
Write the definition of Stock Value under its KPI card in small text. Two people reading the same dashboard should agree on what the number means.
Ravindra Bagale's Tip – मराठी
Stock Value ची व्याख्या त्याच्या KPI card खाली छोट्या अक्षरात लिहा. एकच dashboard वाचणाऱ्या दोघांचं त्या आकड्याच्या अर्थावर एकमत हवं.
Ravindra Bagale's Tip – हिंदी
Stock Value की परिभाषा उसके KPI card के नीचे छोटे अक्षरों में लिखें. एक ही dashboard पढ़ने वाले दो लोगों को उस आँकड़े के मतलब पर सहमत होना चाहिए.
Loading practice tasks...
- Total stock units (Easy): Add up Stock units in the "Stock units" column.
- Average unit cost (Easy): Average of the Unit cost (€) column, rounded to 2 decimals.
- Rows in Antibiotic (Easy): How many rows have Category "Antibiotic"?
- Largest stock units (Easy): The largest value in the "Stock units" column.
- Stock units for Antibiotic (Medium): Total of the Stock units column where Category is "Antibiotic".
- Antibiotic in Madrid (Medium): Total of the Stock units column where Category is "Antibiotic" and City is "Madrid".
- Best in Antibiotic (Medium): Largest value in the "Unit cost (€)" column where "Category" is "Antibiotic".
- Value of row 2 (Medium): Multiply the first-row Stock units by the first-row Unit cost (€).
- Look up Sneha Patil (Medium): The Stock units for "Sneha Patil" (use a lookup on the "Name" column).
- Total value (Hard): Sum of "Stock units" times "Unit cost (€)" for all rows.
- Share of Antibiotic (Hard): Share of the "Stock units" column that is "Antibiotic", rounded to 3 decimals.
- How many rows are above the average "Unit cost (€)" (Hard): Count the rows where "Unit cost (€)" is above the average "Unit cost (€)".
- Above average? (Hard): "Above" if the "Unit cost (€)" value in the first row is above the average of the "Unit cost (€)" column, else "Below".