ISIN Validation (M Function)

ValidISIN function

This article describes the M function syntax and usage of the pqValidISIN M Power Query function in Microsoft Excel.

Description

Returns a boolean result (True or False), indicating whether or not a given String passes the International Securities Identification Number (ISIN) code pattern and Luhn algorithm.

NOTE: This function does not validate the country prefix against the list of ISO recognised countries – nor does it provide any further validation of the codes authenticity.

Syntax

pqValidISIN([INPUT])

The pqValidISIN function has the following arguments:

  • INPUT: Required. The International Securities Identification Number that you want to validate.

Remarks

  • Returns True if strISIN passes the validation check, otherwise returns False.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. Convert the range to a table. If you need to, you can adjust the column widths to see all the data.

CompanyISIN
NEXT PLCGB0032089863
ERROR CHECKNUMGB00B09LQS3X
ABBEY PLCIE0000020408
BARCLAYS PLCGB0031348658
DEBENHAMSGB00B126KH97
ERROR COUNTRYG900B126KH97

Using Power Query, create a new query that is linked to the table (From Table). Add a new custom column to the query table and call it ‘Check’. Implement the following custom column formula:
=pqValidISIN([ISIN])

Close and load the query to see the results in an Excel worksheet.

ISIN validation example table

Installation

Copy the M code below to a BLANK query in Power Query.

Validate an ISIN using Power Query M code

References

One Comment

  1. Pingback: Convert VBA function into Power Query - help needed

Comments are closed