Template:Inflation/TEST/dataset
Appearance
108.560
This sub-template returns the associated country's CPI for a specific year. It's used by {{Inflation/TEST}} for calculating the inflation rate between two given years, which in turn is used by {{Inflation}} to calculate inflated values. It usually isn't meant to be called directly. The information in this dataset is input from "Inflation calculator". Bank of England. London: Bank of England. 18 February 2026. Retrieved 7 March 2026.[a]
Usage
[edit]{{Inflation/TEST/dataset|year}}
Providing no parameter or providing an invalid parameter will result in the "default" CPI, what usually means the latest one.
See also
[edit]- {{Inflation}}
- {{Inflation/TEST}}
- {{Inflation/fn}}
- {{Inflation/year}}
Notes
[edit]- ↑ The data are not immediately visible but are embedded within the webpage. The following script can be used to generate an updated template source by pasting it into the JavaScript console while on the inflation calculator page:
var mths={}, avgs=[], out=['{{#switch:{{{1}}}']; window.boeInflationData.forEach( (v) => { if(v.year.includes(' ')){ const[m,y]=v.year.split(' '); mths[y] = mths[y] || []; mths[y].push(v.value) }else{ out.push('| ' + v.year + ' = ' + v.value); } }); Object.entries(mths).forEach( (v) => { if (v[1].length == 12) { avgs.push(['20'+v[0], v[1].reduce((a, b) => a + b)/12]); } }); avgs.forEach( (v,i,a) => { out.push('| ' + v[0] + ((i<a.length-1) ? ' ' : '\n| #default') + '= ' + v[1]); }); out.push('<!'+'-- *** When changing this, also update the reference in [[Template:Inflation/fn]] and the latest year in [[Template:Inflation/year]]! *** --'+'>'); out.push('}}<noinclude>{{documentation|Template:Inflation/doc/cpi-uk}}[[Category:United Kingdom data templates]]</noinclude>'); console.log(out.join('\n'));