Skip to main content

Featured

Space Explorers Book 7: Answers and Explanations

Memunic Space Explorers › Book 7: Memoon and the Search for Another Home › Answers and Explanations Answers and Explanations Habitable means life could live there; inhabited means life does live there. A world can be habitable and empty, as an unoccupied flat has a roof and water but nobody in it. The Moon has almost no air, so water would boil or freeze, and its gravity is only about one-sixth of Earth’s, too weak to keep air. Accept also: no greenhouse blanket, so it swings between very hot and very cold. Venus. It matches Earth in size and roughly in mass, but its thick carbon dioxide air traps heat, making it hot and crushing. “Twin” is only true for size and weight. A dip of 1 per cent means (planet width divided by star width) squared is 0.01, so the ratio is 0.1: the planet is about a tenth as wide as the star. Repeats at the same gap show the planet is going round the star in 12 days, and rule out a one-time event such as a passing object. A planet shines only by reflected l...

Byte by Byte Book 7: Chapter 13 – Advanced Spreadsheets

Byte by Byte › Book 7: Networks, Programming and Machine Learning › Chapter 13: Advanced Spreadsheets

Chapter 13: Advanced Spreadsheets

You will learn: relative, absolute and mixed cell references, named ranges, percentages and percentage change, nested IF and IFS with AND and OR, conditional functions (COUNTIF, COUNTIFS, SUMIF, SUMIFS, AVERAGEIF), looking up data with XLOOKUP and VLOOKUP, data validation, conditional formatting with formulas, PivotTables and PivotCharts, choosing charts, Goal Seek, common error values, and how spreadsheets can mislead.

🔎 The Case

Tally spread her printouts across the desk and tapped them with her pencil. "Every forward of the clips, from every village, by every kind of account, on Monday and Tuesday."

"Monday was before the explainer and the app," said Memoon. "Tuesday was after."

"Exactly. So we can measure what happened, instead of guessing." Tally pushed her visor up. "In the Games last year you used Excel for medal tables: SUM, AVERAGE, IF, charts. Good. Today you'll need the grown-up tools. Questions like: what percentage did forwarding fall in each village? Which kind of account still does most of the forwarding? And if we want forwards down to almost nothing, how many more people need the app?"

Vega looked at the eighteen-thousand-row printout. "You want us to type all that?"

"Certainly not," said Tally. "The hub summarised it for us. Twenty rows. And twenty well-organised rows, with the right formulas, can tell you more than eighteen thousand messy ones."

💡 The Concepts

Remember from Book 5. A spreadsheet is a grid of cells, each named by its column letter and row number (B3). A formula starts with = and can use functions such as =SUM(D2:D21) . When you copy a formula with AutoFill (dragging the fill handle at the bottom-right corner of a cell), its cell references change to match their new position. This chapter builds on all of that.

Relative, absolute and mixed references. A normal reference such as D2 is a relative reference: when the formula is copied one row down, it becomes D3 . Usually that is what you want. But sometimes a formula must keep pointing at one fixed cell, such as a total. Then you need an absolute reference, written with dollar signs: $D$23 . The dollar sign locks the part after it.

ReferenceColumn when copied sidewaysRow when copied downType
D2ChangesChangesRelative
$D$23FixedFixedAbsolute
$A2FixedChangesMixed (column locked)
B$1ChangesFixedMixed (row locked)

To find each row's share of the total forwards, the formula in E2 is =D2/$D$23 . Copied down to E3, it becomes =D3/$D$23 : the first part moved, the total did not. Without the dollar signs, E3 would wrongly say =D3/D24 , an empty cell, and show the error #DIV/0! .

Shortcut: while typing a formula, click in a reference and press F4. Each press cycles through D23 , $D$23 , D$23 and $D23 .

Named ranges. Instead of $D$23 , you can give a cell or range a name. Select D23, click in the Name Box (left of the formula bar), type Total and press Enter. Now =D2/Total works anywhere in the workbook, and is far easier to read. Names are always absolute.

Percentages. A percentage is a fraction of 100. In Excel, calculate the fraction ( =D2/$D$23 gives 0.2007...) and then click Home → % (Percent Style) to show it as 20%. Use Increase Decimal to show 20.1%. Never multiply by 100 and use Percent Style, or you get 2007%.

Percentage change compares a new value with an old one:

percentage change = (new − old) ÷ old

In Excel: =(C2-B2)/B2 , formatted as a percentage. A negative answer is a decrease. Moonbrook went from 2,790 forwards to 590: (590 − 2,790) ÷ 2,790 = −78.9%.

Nested IF and IFS. In Book 5 you used IF with two outcomes. To choose between three or more, put an IF inside another IF . This is a nested IF:

=IF(D2>=1000, "High", IF(D2>=300, "Medium", "Low"))

Excel checks the conditions in order, like if / elif / else in Python (Book 6). The IFS function does the same more neatly: =IFS(D2>=1000, "High", D2>=300, "Medium", TRUE, "Low") . The final TRUE acts like else .

AND, OR and NOT combine conditions, as in Python: =IF(AND(A2="Mon", D2>500), "Busy Monday", "") and =IF(OR(B2="Moonbrook", B2="Riverbend"), "River valley", "Hills") .

Conditional functions. These functions count, add or average only the rows that meet conditions.

FunctionExampleMeaning
COUNTIF(range, criteria)=COUNTIF(D2:D21, ">1000")How many forward counts are over 1,000
COUNTIFS(range1, criteria1, range2, criteria2, ...)=COUNTIFS(A2:A21, "Mon", D2:D21, ">500")How many Monday rows have over 500 forwards
SUMIF(range, criteria, sum_range)=SUMIF(C2:C21, "New", D2:D21)Total forwards by new accounts
SUMIFS(sum_range, range1, criteria1, ...)=SUMIFS(D2:D21, A2:A21, "Mon", C2:C21, "New")Total forwards by new accounts on Monday
AVERAGEIF(range, criteria, average_range)=AVERAGEIF(C2:C21, "New", D2:D21)Average forwards per row for new accounts

Conditions with comparisons go in quotes: ">1000" , "<>Snowpeak" (not equal to). Watch the argument order: SUMIF puts the range to add last, but SUMIFS puts it first.

Looking up data. A lookup finds a value in one column and returns the matching value from another, like looking up a key in a Python dictionary (Chapter 7).

XLOOKUP is the modern lookup function in Microsoft 365 and Excel for the web:

=XLOOKUP(B2, $H$2:$H$6, $I$2:$I$6, "none")

This means: look for the village in B2 down the list H2:H6; return the value in the same position from I2:I6; if not found, show "none". The ranges are absolute so the formula can be copied down.

Older versions of Excel use VLOOKUP (vertical lookup): =VLOOKUP(B2, $H$2:$I$6, 2, FALSE) . It looks in the first column of the table H2:I6 and returns the value from column number 2 of that table. The FALSE means "exact match only"; forgetting it is one of the most common spreadsheet mistakes. XLOOKUP is easier and safer, but you will see VLOOKUP in many existing spreadsheets.

Data validation. Data validation controls what can be typed into a cell, catching mistakes before they happen (you did this in code in Book 6 and Chapter 10). Select the cells, then Data → Data Validation:

  • List: a drop-down of allowed values, such as Mon,Tue or New,Old .
  • Whole number or Decimal between a minimum and maximum, such as forwards from 0 to 100000.
  • Date within a range.
  • Input Message shows a hint when the cell is selected; Error Alert shows a message when the rule is broken.

Conditional formatting with formulas. In Book 5 you highlighted cells above a value. With Home → Conditional Formatting → New Rule → Use a formula to determine which cells to format, you can format whole rows using a formula. Select A2:D21 and enter =$C2="New" with a pale orange fill: every row where column C says New turns orange. The $ locks column C, so every cell in the row checks column C, while the row number changes.

Other useful formats: Data Bars (a bar inside each cell showing its size), Color Scales (a colour gradient from low to high) and Icon Sets (arrows or traffic lights).

Sorting and filtering, again. Data → Sort can sort by several levels: for example by Day, then by Forwards from largest to smallest. Freeze Panes (View → Freeze Panes → Freeze Top Row) keeps headings visible while you scroll through long data.

PivotTables. A PivotTable summarises a large table in seconds, without writing any formulas. You choose which fields to group by and what to calculate, and Excel builds the summary. You can rearrange ("pivot") it by dragging fields.

To make one: click anywhere in the data, then Insert → PivotTable → OK (a new sheet is created). In the PivotTable Fields pane, drag fields into four areas:

AreaWhat it doesIn our example
RowsOne row per valueVillage
ColumnsOne column per valueDay
ValuesWhat to calculate (Sum, Count, Average)Sum of Forwards
FiltersShow only some dataAccount (New or Old)

The result:

Sum of ForwardsMonTueGrand Total
Moonbrook2,7905903,380
Palace Town2,3105002,810
Pebble Hollow1,2603501,610
Riverbend1,7904402,230
Snowpeak550130680
Grand Total8,7002,01010,710

If the source data changes, right-click the PivotTable and choose Refresh. A PivotChart (PivotTable Analyze → PivotChart) draws a chart that changes whenever the PivotTable does.

Choosing the right chart. You learned chart types in Books 5 and 6. The rule is to choose the chart that answers the question.

QuestionChart
How do categories compare?Column or bar chart
How did something change over time?Line chart
What share of the whole does each part make? (a few parts only)Pie or doughnut chart
Are two numbers related?Scatter chart (Book 6)
Two measures with different scales togetherCombo chart (columns plus a line on a second axis)

Give every chart a clear title and axis titles, with units.

What-if analysis and Goal Seek. A spreadsheet model lets you ask "what if?" by changing an input and watching the results update. Goal Seek works backwards: you choose the result you want, and Excel finds the input that produces it.

Tally's simple model predicts daily forwards as =5000-8*B26 , where B26 is the number of villagers using the app. To find how many users would bring forwards down to 1,000: Data → What-If Analysis → Goal Seek; Set cell: the formula cell; To value: 1000; By changing cell: B26. Excel answers 500. (A model is only as good as its formula: real life is rarely this simple, as Chapter 14 will show.)

Error values. When a formula cannot work, Excel shows an error value. Knowing what each means saves time.

ErrorMeaningCommon cause
#DIV/0!Division by zeroDividing by an empty cell, often a missing $
#N/AValue not availableA lookup could not find a match
#NAME?Excel does not recognise a nameA spelling mistake in a function name, or text without quotes
#VALUE!Wrong type of valueDoing arithmetic on text
#REF!Invalid cell referenceA cell the formula used has been deleted
####Not an errorThe column is too narrow: widen it

=IFERROR(formula, "message") shows a friendly message instead of an error.

How spreadsheets can mislead. Numbers feel objective, but the way they are presented can mislead, deliberately or by accident (Book 5).

  • A chart whose vertical axis does not start at zero can make a small difference look huge.
  • Percentages without the real numbers can mislead: "forwards in Snowpeak rose 100%" sounds alarming, but might mean 2 forwards instead of 1.
  • Averages hide extremes: one huge value can pull the average far from what is typical (that is why the median exists).
  • Correlation is not causation (Book 6): forwards fell after the explainer, but something else might also have changed that day.

Real World: Government open-data portals such as data.gov.in publish thousands of datasets, from rainfall and crop production to school enrolment, as downloadable spreadsheets. Journalists, researchers and students analyse them with exactly the tools in this chapter.

Career Spotlight: Data analyst. Data analysts turn raw data into answers for businesses, hospitals, governments and sports teams. Spreadsheets, PivotTables and charts are their everyday tools, along with Python (Book 8) and databases (Book 6).

Illustration from Byte by Byte Book 7: Chapter 13 – Advanced Spreadsheets

🛠️ Build It

Create a new Excel workbook and save it as Clip Forwards in Documents.

Activity 1: Enter the data. In the first sheet (rename it Forwards), type these headings in A1:D1 and the twenty rows below them (A2:D21). Use Data Validation lists for columns A ( Mon,Tue ) and C ( New,Old ) before you start typing.

DayVillageAccountForwards
MonMoonbrookNew2150
MonMoonbrookOld640
MonRiverbendNew1380
MonRiverbendOld410
MonPebble HollowNew960
MonPebble HollowOld300
MonPalace TownNew1720
MonPalace TownOld590
MonSnowpeakNew430
MonSnowpeakOld120
TueMoonbrookNew380
TueMoonbrookOld210
TueRiverbendNew290
TueRiverbendOld150
TuePebble HollowNew240
TuePebble HollowOld110
TuePalace TownNew310
TuePalace TownOld190
TueSnowpeakNew90
TueSnowpeakOld40

("New" means an account less than a month old.) Freeze the top row.

Activity 2: Absolute references.

  1. In C23 type Total and in D23 type =SUM(D2:D21) . You should get 10710.
  1. In E1 type Share . In E2 type =D2/$D$23 , press Enter, and format it as a percentage with one decimal place. You should see 20.1%.
  2. AutoFill E2 down to E21. Click E3 and read its formula in the formula bar. Which part changed, and which did not?
  3. Now try it the wrong way: in F2 type =D2/D23 and fill it down. What appears, and why?
  4. Delete column F. Then name D23 Total with the Name Box, and change E2 to =D2/Total . Fill down again.

Activity 3: Levels with nested IF. In F1 type Level . In F2 type =IF(D2>=1000, "High", IF(D2>=300, "Medium", "Low")) and fill down. How many rows are High? Then add a conditional formatting rule to A2:F21 using the formula =$C2="New" with a light orange fill.

Activity 4: Conditional functions. In H1 to H6 type these labels, and in I1 to I6 the formulas. Check your answers.

Label (H)Formula (I)Answer
Rows over 1000=COUNTIF(D2:D21, ">1000")3
Busy Monday rows=COUNTIFS(A2:A21, "Mon", D2:D21, ">500")6
New-account forwards=SUMIF(C2:C21, "New", D2:D21)7950
New on Monday=SUMIFS(D2:D21, A2:A21, "Mon", C2:C21, "New")6640
Average per New row=AVERAGEIF(C2:C21, "New", D2:D21)795
New share of all=I3/Total74.2%

Activity 5: Lookup. In K1:L6 type a small table of Truth Desk volunteers: K1 Village , L1 Volunteer ; then Moonbrook / Luna, Riverbend / Ribbit, Pebble Hollow / Spike, Palace Town / Pip, Snowpeak / Vega. In G1 type Volunteer and in G2 type =XLOOKUP(B2, $K$2:$K$6, $L$2:$L$6, "none") . Fill down. (If your Excel has no XLOOKUP, use =VLOOKUP(B2, $K$2:$L$6, 2, FALSE) .) Change "Snowpeak" in K6 to "Snow Peak". What happens in column G? Change it back.

Activity 6: PivotTable and PivotChart.

  1. Click any cell in A1:D21, then Insert → PivotTable → OK.
  1. Drag Village to Rows, Day to Columns, and Forwards to Values. Check your table matches the one in The Concepts.
  2. Drag Account to Filters, then choose only New. What were the Monday and Tuesday totals for new accounts?
  3. Click inside the PivotTable, then PivotTable Analyze → PivotChart → Clustered Column → OK. Add the title Forwards of the clips, before and after.
  4. Next to the PivotTable, calculate each village's percentage change with =(C5- B5)/B5 (adjust the cells to match where your Mon and Tue numbers are). Which village fell the most?

Activity 7: Mixed references. On a new sheet, type 1 to 10 in B1:K1 and 1 to 10 in A2:A11. In B2 type =$A2*B$1 . Fill it right to K2, then fill B2:K2 down to row 11. You have built a complete multiplication table with one formula. Explain why each $ is where it is.

Activity 8: Goal Seek. In the Forwards sheet, type App users in A26 and 0 in B26; type Predicted forwards in A27 and =5000-8*B26 in B27. Use Data → What-If Analysis → Goal Seek to find how many app users would bring predicted forwards down to 1,000, and then to 200. What answers do you get? Why might a real result be different?

Unplugged: Human PivotTable. Give each person a card showing one row of the data (day, village, account, forwards). Ask everyone to stand in groups by village. A "calculator" adds up each group. Then regroup by day, then by account type. Each regrouping is a pivot. How long did it take compared with Excel?

✅ Case Closed

Tally's PivotTable told the story at a glance. Forwards of the clips had fallen from 8,700 on Monday to 2,010 on Tuesday: a fall of 76.9%. Every village had fallen by more than 70%. Moonbrook, where most forwards had begun, had fallen the most: 78.9%.

"The explainer and the app worked," said Pip, delighted.

"Something worked," said Tally. "Correlation is not causation. But it's a very good sign."

Then she switched the filter to New accounts, and the room went quiet again. On Monday, new accounts had made 76.3% of all forwards. On Tuesday, even after the echo birds had been fixed, they still made 65.2%.

"Someone is still making accounts," said Vega. "Not with birds this time. By hand, or some other way. And they're using them to push the clips."

And there was something worse. While they had been working, the Mirror had published three new clips. Every day, there would be more. Each one had to be checked by hand, frame by frame, by people who were already exhausted.

"We can't keep up," said Memoon. "We need something that can look at a clip and tell us if it's likely to be fake. Something that learns."

Nimo floated up from the corner, where he had been quietly listening all evening. "Then it's time," he said, "to build an AI. Properly. From the beginning."

❓ Test Yourself

  1. What is the difference between a relative and an absolute cell reference? Write an example of each.
  2. The formula in E2 is =D2/$D$23 . What will it be when copied to E7? And to F2?
  3. What do $A2 and B$1 lock? What kind of reference are they?
  4. What does pressing F4 do while editing a formula?
  5. Last year 400 students used the library; this year 520 did. Calculate the percentage change. Write the Excel formula if last year is in B2 and this year in C2.
  6. Write a nested IF that shows "A" for marks of 90 or more, "B" for 75 to 89, and "C" for anything lower, for a mark in B2.
  7. Write formulas to: (a) count the cells in C2:C50 equal to "Riverbend", (b) add D2:D50 only where C2:C50 is "Riverbend", (c) add D2:D50 where C is "Riverbend" and A is "Mon".
  8. What does XLOOKUP do? What does the fourth argument, such as "none", do?
  9. What do the four areas of a PivotTable do?
  10. What is Goal Seek used for?
  11. What do these errors mean: #DIV/0! , #N/A , #NAME? ?
  12. Give two ways a chart or a percentage could mislead a reader.
  13. Challenge: Using your class's real (anonymous) data, such as hours of sleep, minutes of screen time and travel time to school, build a workbook with data

validation, a PivotTable, a chart answering one clear question, and a short written conclusion that says what the data does and does not prove.

📚 Key Terms

  • Relative reference: a cell reference that changes when the formula is copied, such as D2 .
  • Absolute reference: a cell reference that stays fixed when copied, such as $D$23 .
  • Mixed reference: a reference with only the column or only the row locked, such as $A2 .
  • Named range: a name given to a cell or range, used in formulas.
  • Percentage change: (new − old) ÷ old, shown as a percentage.
  • Nested IF: an IF function inside another IF function.
  • IFS: a function that tests several conditions in order.
  • COUNTIF / COUNTIFS: count cells that meet one / several conditions.
  • SUMIF / SUMIFS: add cells that meet one / several conditions.
  • AVERAGEIF: average the cells that meet a condition.
  • Lookup: finding a value and returning a matching value from another column.
  • XLOOKUP / VLOOKUP: the modern / older lookup functions.
  • Data validation: rules that control what can be entered in a cell.
  • Conditional formatting: formatting that changes depending on cell values.
  • PivotTable: an interactive summary of a table, grouped by chosen fields.
  • PivotChart: a chart linked to a PivotTable.
  • Combo chart: a chart that combines two chart types, often with two axes.
  • What-if analysis: changing inputs to see how results change.
  • Goal Seek: finding the input that gives a chosen result.
  • Error value: a code such as #DIV/0! showing why a formula failed.
  • IFERROR: a function that replaces an error with a chosen value.

Keep learning with Byte by Byte

Explore Book 7: Networks, Programming and Machine Learning. Find the ebook, purchase details and teaching slides on MemuniCity.

Watch this chapter on YouTube

Comments

Popular posts from this blog

CA-7 Job Status and Failure Reason Codes

Here are the various status codes that You may see for jobs in the Queue or Logs in CA-7. R-C0002 R-C0003 R-C0099 R-C0255 R-JCLER A-U0002 A-U0004 A-U0015 A-U0043 A-U4095 A-SOC7 A-U4000 Reason Code/Job Status Code explanation: The indication of the job's current disposition. Values and their meanings are: A-Snnnn-- The job has failed with a system abend. A-Unnnn --The job has failed with a user abend. C-Cnnnn --The job has completed successfully and is going through completion processing. E-ARFATT-- An error occurred during the attempt to attach ARF definitions. This can result if the ARFSET specified is not defined. A diagnostic message may have been written to the CA-7 log, the OS console, or to the trailer queue for the job (in which case it can be displayed using LQ,JOB=x,LIST=ALL). E-ARFERR ---The job encountered an error in the ARF processing. Do a LARFQ command for the job to get more specific information. E-SEGERR --The job has been requeued...

Whistling Winds and Waterfalls: 4 Days of Magic in Shillong

Nestled in the clouds, where the scent of pine trees mingles with the rhythm of waterfalls and the tunes of local guitar-strumming youth—Shillong is more than a place. It’s a vibe. If you’ve got 3 nights and 4 days, you’ve got just enough time to fall in love. Here’s how to make the most of it—food, fun, fog and fantastic views included. Day 1: Shillong, We’re Coming for You! You land in Guwahati, barely out of the airport when the hills start calling. You hop into your cab, Spotify on, windows down, and the three-hour ride to Shillong begins. Just when you think it can’t get better, you stop at Umiam Lake —a lake so calm, it looks like someone ironed the water. By evening, you’re sipping hot chai in Laitumkhrah, maybe nibbling on spicy momos or pork jadoh from a roadside stall. You’re checked into your charming hotel ( Tripura Castle if you fancy old-world royalty, Ri Kynjai if you’re into lakeside poetry). The breeze whispers secrets of waterfalls and pine forests. Sleep well, drea...

Installing and Configuring Hadoop on Ubuntu as a Pseudo Distributed Single Node Cluster

Briefly what is psuedo-distributed single node Hadoop cluster: It is a Hadoop distributed cluster having Single Node. All the five daemons (NN,DN,JT,TT,SNN) are running as individual JVM (java process) instances. We will get all distributed features of Hadoop. This mode is used to develop, test, and staging (before production) Map Reduce programs quickly. It writes all the system, daemon and user logs to different files on the cluster To install Hadoop in this mode, we have to modify the hadoop-env.sh, core-site.xml, hdfs-site.xml, mapred-site.xml. hadoop-env.sh contains all the Environment variables which are required for running Hadoop. All the default values are fine, Only we have to modify the JAVA_HOME=“The location of Java Home Directory” Core-site.xml contains all the cluster specific information like io, temp directory, sorting, file system uri etc. Hdfs-site.xml contains all the parameters which are specific to HDFS like name node directory, data node directory...