column_ifexists()
Applies to: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Displays the column, if the column exists. Otherwise, it returns the default column.
Deprecated aliases: columnifexists()
Syntax
column_ifexists(
columnName,
defaultValue)
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
columnName | string |
✔️ | The name of the column to return. |
defaultValue | scalar | ✔️ | The default column to return if columnName doesn't exist in the table. This value can be any scalar expression. For example, a reference to another column. |
Returns
If columnName exists, then returns the column. Otherwise, it returns the defaultValue column.
Example
This example returns the default State column, because a column named Capital doesn't exist in the StormEvents table.
StormEvents | project column_ifexists("Capital", State)
Output
This output shows the first 10 rows of the default State column.
State |
---|
ATLANTIC SOUTH |
FLORIDA |
FLORIDA |
GEORGIA |
MISSISSIPPI |
MISSISSIPPI |
MISSISSIPPI |
MISSISSIPPI |
AMERICAN SAMOA |
KENTUCKY |
... |