Mall:Inflation/dok

Från Wikipedia

Denna mall använder paramaterarna landskod, exempelvis, "US" för USA eller "UK" för Storbritannien, ett värde i landets valuta, ett startår, och applicerar detta på landets prisinflation fram till "nutid".[1] Detta betyder att närhelst ett nytt år inleds, kommer alla artiklar som använder denna mall få deras visade värde uppdaterat.

Alternativt kan man, om man vill, ange parametern slutår. Värdet kommer då beräknas mellan två år, vilket ger en bekväm väg att få värden från olika tidsperioder justerade kring samma år.

Användning[redigera wikitext]

{{Inflation|landskod|värde|startår|r=digit}}
{{Inflation|landskod|värde|startår|slutår|r=digit}}

Där:

  • landskod och startår kan se ut som följer:
Country name country_code start_year
Tyskland[2] DE 1882
Storbritannien[3] UK 1264
USA[4] US 1800
  • slutår, om angivet, måste vara högre (senare) än startår, men inte högre än innevarande år, och kommer automatiskt vara "nutid" om utelämnat;
  • r=digit anger antalet decimaler som värdet ska rundas av till, satt till "0" om det ej angetts, i.e., utan hundradelar (se Tips & Tricks nedan för dealjer om hur man använder denna parameter).

Exempel:

Inkorrekta parameterval resulterar i en länk till artikeln NaN:


Användning[redigera wikitext]

Tips & Trick[redigera wikitext]

Valutaomvandling[redigera wikitext]

Denna mall är valutabunden, vilket betyder att den inte konverterar mellan olika valutor. Detta innebär att om du ville veta hur många 1 000 D-mark 1960 är värt idag, genom att ange {{Inflation|DE|1000|1960|r=2}} skulle du få resultatet (NaN) vilket fortfarande är i mark, ej i euro.

Följaktligen innebär detta att om du behöver ett resultat i en annan valuta än den som den ursprungliga, måste du för närvarande göra omvandlingen manuellt och i följande exempel som använder det egna angivna omvandlingsvärdet 1 € = 1.95583 D-mark:

  • {{#expr:({{Inflation|DE|1000|1960|r=2}} / 1.95583) round 2}} = Fel i uttryck: Okänt skiljetecken "["

A currency conversion template to ease these conversion tasks is planned. This section will be updated accordingly once it's developed.

Rounding[redigera wikitext]

By default the values are calculated to the unit, as for most huge values cents are undesirable. If you need a different precision you can provide the |r= parameter to determine in which digit the rounding must happen. To obtain cents you'd use |r=2, but other values can be used, including negative ones: |r=-3, for example, will round to the nearest thousand, |r=-6 to the nearest million, and so on and so forth.

Formatnum[redigera wikitext]

For a better visualization you can format the returned value using either the internal {{formatnum:}} magic word, or the alternative {{Formatprice}} template (see below). Each method has its advantages and disadvantages.

{{formatnum:}} is the standard method for formatting numbers in MediaWiki. It add thousands and decimal separators according to the user settings, and works well for raw numbers composed of up to 15 digits and a dot. On the other hand, it doesn't allow one to set how many digits must be shown after the decimal dot. Thus, a calculated value of "1234.5" will appear as "1 234,5", not the expected "1,234.50", making it better suited for integer prices unless the value is known and you can add the missing zeros by hand:

  • DM {{formatnum:{{Inflation|DE|1000000|1957|1978}}}}.00 = DM NaN.00
  • £{{formatnum:{{Inflation|UK|1000000|1323|1978|r=-4}}}} = £NaN
  • ${{formatnum:{{Inflation|US|1000000|1990|r=2}}}} = $1 917 727,97

Another potential source of difficulties resides in the way certain calculated values are expressed. In many cases the result comes as a number in engineering units ("1.2E+9" instead of "1200000000"), and when that happens {{formatnum:}}'ing the result fails. A workaround then is to express the value to be inflated with less digits, adding a multiplier text such as "million" after the result, and then hitting the "Show preview" button as many times as needed, changing parameters until the best result is found:

  • ${{formatnum:{{Inflation|US|1000000000|1900|r=-8}}}} = $30 100 000 000
  • ${{formatnum:{{Inflation|US|1000000|1900|r=-5}}}} thousand = $30 100 000 thousand
  • ${{formatnum:{{Inflation|US|1000|1900|r=-2}}}} million = $30 100 million
  • ${{formatnum:{{Inflation|US|1|1900|r=1}}}} billion = $30,1 billion

The following section provides an automated way of avoiding this trial and error scenario.

Formatprice[redigera wikitext]

{{Formatprice}} is a template specifically designed to display price values, both big and small, in a more pleasant way than {{formatnum:}} allows for. For example, instead of showing the whole of a huge number such as "953,783,409,856.12", it would show it as "954 miljarder", while small numbers have their cents part appearing as expected, "1234.5" being properly shown as "1,23 tusen".

On the down side, {{Formatprice}} has no built-in intelligent handling of user locale settings, what means that some users might see a dot or a comma the opposite way they'd expect. As a general rule of thumb this shouldn't be a serious concern though, as most numbers in Wikipedia are hand-written anyway and will show as entered regardless of user settings.

Documenting[redigera wikitext]

It's a good practice to provide a valid reference for the prices calculated with this template in the articles where it's used. The template {{Inflation-fn|country}} was developed to ease this task. It accepts as its single parameter the same country codes used here, and will generate one or more appropriate footnotes. Typically, this is how a piece of text using it looks like:

  • In 1910 a ''blah'' cost on average £1,000. This is equivalent to £{{Formatprice|{{Inflation|UK|1000|1910|r=2}}}} in present day terms.{{Inflation-fn|UK}}

Resulting in this converted code (notice the footnote link at the end):

  • In 1910 a blah cost on average £1,000. This is equivalent to £NaN in present day terms.[3]

The footnote thus generated appears whenever {{reflist}} or <references /> is used in an article, usually in its "References" section. See below for the live example in this document's own References section, or click the above generated footnote to jump to it.


Limitations[redigera wikitext]

  1. Currently it isn't possible to "de-inflate" a value to what it would have been in a previous year. If you need this functionality, please request it at the talk page. Adding it won't be difficult, but there's no point in doing so before someone actually needs it.
  2. Substitution isn't supported at all. Trying to {{subst:Inflation|...}} would only result in a long sequence of embedded parser code without any direct benefit. If you need to obtain an inflated price only once, please use the special ExpandTemplates page then copy the result and paste it at the desired location.

Parametrar[redigera wikitext]

Exempel[redigera wikitext]

Associerad kategori[redigera wikitext]

Källor[redigera wikitext]

  1. ^ Hur nära i nutid beror på hur datan för varje land är sammansatt och på interna tabeller som ska uppdateras i början av varje år. Några datatabeller ger inflationsdata fram till 31 december 2023, andra till omkring juni-juli 2023, och andra till och med 31 december 2022.
  2. ^ Tysklands inflationtal baserade på data som finns på Deutsches Statistisches Bundesamt.
  3. ^ [a b] Storbritanniens inflationtal baserade på data som finns på Measuring Worth: UK CPI.
  4. ^ USA:s inflationstal baserade på data som finns på Consumer Price Index (estimate) 1800–2018. Federal Reserve Bank of Minneapolis.

Se även[redigera wikitext]

</includeonly>