Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Number.PI Function: How to Use It

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Power Query's Number.PI function returns the mathematical constant pi (π ≈ 3.141592653589793) as a number, so you can use it inside custom columns, calculated tables, or any M expression that needs π. To use it, open the Power Query Editor, add a step that calls Number.PI(), and load the result back to your workbook or data model. No arguments are required, and the function is available in Excel, Power BI, and other tools that use the Power Query engine.

What You'll Need

  • A version of Excel, Power BI Desktop, or another tool that includes the Power Query Editor. In Excel, the feature is called Get & Transform Data on the Data tab.
  • A data source loaded into Power Query, or permission to create a blank query if you just want to test the function.
  • Basic familiarity with the Power Query Editor and the formula bar. You do not need to write full M code from scratch, but you will type or edit a short expression.

Step-by-Step

  1. Open the Power Query Editor. In Excel, go to the Data tab and choose Get Data, then pick a source, or use From Table/Range to bring in existing data. In Power BI Desktop, choose Transform Data from the Home ribbon. The editor opens in a separate window.
  2. Decide where you need pi. You can add it as a new custom column, use it inside an existing calculated step, or create a standalone query that returns the value. For most users, a custom column is the simplest route.
  3. Add a custom column. On the Add Column tab, click Custom Column. In the dialog, give the column a name such as PiValue. In the formula box, type Number.PI() exactly, including the empty parentheses. Click OK.
  4. Check the result. A new column appears with the value 3.141592653589793 in every row. If the column shows an error, the expression was typed incorrectly; see the troubleshooting section below.
  5. Use pi in a calculation. If you want to multiply an existing column by pi, edit the custom column formula to something like [Diameter] * Number.PI(). The function returns a number, so it works with arithmetic operators and other number functions.
  6. Create a standalone query (optional). If you only need the value itself, go to Home > New Source > Blank Query, then open the Advanced Editor and replace the default code with let Source = Number.PI() in Source. Close and load the query to see the single value.
  7. Apply and load. When your column or query is correct, click Close & Load (Excel) or Close & Apply (Power BI) to send the result back to your worksheet or data model.

Menu labels can differ slightly between versions, platforms, and regions, but the core steps above are the same in current releases.

Common Mistakes

  • Omitting the parentheses. Number.PI is a function, so it must be written as Number.PI(). Typing just Number.PI usually produces an error or an unexpected result.
  • Using a comma or other separator inside the parentheses. The function takes no arguments, so Number.PI(3) or Number.PI(1) is invalid.
  • Confusing the column name with the function. If you name your custom column Number.PI, Power Query may treat it as a field reference rather than a function call. Use a different name such as PiValue.
  • Expecting a text result. Number.PI returns a number, not text. If you need it as text, wrap it with Number.ToText, but that is rarely necessary.
  • Forgetting to load the query. Adding a step in the editor does not update your worksheet until you close and load.

Tips

  • Use Number.PI() directly in formulas instead of hard-coding 3.14159; this avoids rounding differences and makes your intent clear.
  • If you need pi rounded to a specific number of decimals, combine it with Number.Round, for example Number.Round(Number.PI(), 2) for 3.14.
  • Store the value once in a small query and reference it from others if you use pi in many places; this keeps your logic consistent.
  • Remember that Power Query is case-sensitive for function names in M; write Number.PI with the capital letters as shown.
  • When building a custom column, you can click the fx button next to the formula bar to open the full expression editor, which is easier for longer formulas.

Troubleshooting

If the custom column shows an error, first check that you typed Number.PI() with both parentheses and no extra characters. Click the error link in the cell to see the exact message; common messages mention an unrecognized identifier or a token error. If you are editing an existing step, make sure the step name is not the same as the function name. If the function is not recognized at all, confirm you are in the Power Query Editor and not in a regular Excel formula; Number.PI is an M function, not a worksheet function.

If the value appears as text or with a different number of decimals, check the column's data type. Set it to Decimal Number or Whole Number as appropriate. If you see a locale-related error, ensure your system's list separator matches what you typed; in some regions the comma is used differently, but Number.PI() has no arguments so this is rarely the cause.

If the query loads but the column is missing, verify that you applied the step and that the custom column was added to the correct table. In Excel, check that the query output is not being overwritten by another query. If you created a standalone query and it shows a table instead of a single value, that is normal; Power Query always returns a table, and you can drill down to the value if needed.

Frequently Asked Questions

What does Number.PI return?

It returns the constant pi as a decimal number, approximately 3.141592653589793, with the precision supported by the Power Query engine.

Can I use Number.PI in a calculated column in Power BI?

Yes, you can use it in any Power Query expression, including custom columns added in the Power Query Editor. It is not available in DAX, which has its own PI function.

Does Number.PI require any arguments?

No. The function takes no arguments, so you must include the empty parentheses: Number.PI().

How do I round the value of pi in Power Query?

Wrap the function in Number.Round, for example Number.Round(Number.PI(), 4) to get 3.1416.

Is Number.PI available in Excel's Power Query?

Yes, it is part of the standard M library included with Excel's Power Query Editor, as well as Power BI Desktop and other Power Query hosts.

What if I get an error saying the name is not recognized?

Check for typos, ensure you are in the Power Query Editor, and confirm the function name is capitalized exactly as Number.PI. If the error persists, try creating a new blank query and testing the function there to isolate the issue.