|
| 1 | +--- |
| 2 | +description: "Learn more about: INFO.VIEW.COLUMNS" |
| 3 | +title: "INFO.VIEW.COLUMNS function (DAX)" |
| 4 | +author: DataZoeMS |
| 5 | +--- |
| 6 | +# INFO.VIEW.COLUMNS |
| 7 | + |
| 8 | +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] |
| 9 | + |
| 10 | +Returns a table with information about each column in the semantic model, such as name, description, and format string. This information helps you understand the model and to self-document the model when used in calculated tables. |
| 11 | + |
| 12 | +## Syntax |
| 13 | + |
| 14 | +```dax |
| 15 | +INFO.VIEW.COLUMNS() |
| 16 | +``` |
| 17 | + |
| 18 | +## Return value |
| 19 | + |
| 20 | +A table with the following columns: |
| 21 | + |
| 22 | +| Column | Description | |
| 23 | +|---|---| |
| 24 | +| [ID] | The unique ID for each column in this semantic model as an integer. | |
| 25 | +| [Name] | The name of each column in this semantic model as a string. | |
| 26 | +| [Table] | The table of each column in this semantic model as a string. | |
| 27 | +| [DataType] | The data type of each column in this semantic model as a string. | |
| 28 | +| [DataCategory] | The data category of each column in this semantic model as a string. | |
| 29 | +| [Description] | The description of each column in this semantic model as a string. | |
| 30 | +| [IsHidden] | The hidden state of each column in this semantic model as True or False. | |
| 31 | +| [IsUnique] | The is unique of each column in this semantic model as True of False. | |
| 32 | +| [IsKey] | The is key of each column in this semantic model as True or False. | |
| 33 | +| [IsNullable] | The is nullable of each column in this semantic model as True or False. | |
| 34 | +| [Alignment] | The alignment of each column in this semantic model as a string. | |
| 35 | +| [SummarizeBy] | The summarize by of each column in this semantic model as a string. | |
| 36 | +| [ColumnStorage] | The column storage of each column in this semantic model as a string combination of name and ID. | |
| 37 | +| [Type] | The type of each column in this semantic model as a string. | |
| 38 | +| [SourceColumn] | The source column of each column in this semantic model as a string. | |
| 39 | +| [Expression] | The DAX formula of calculated columns. | |
| 40 | +| [FormatString] | The format string of each column in this semantic model as a string. | |
| 41 | +| [IsAvailableInMDX] | The is available in MDX of each column in this semantic model as True or False. Analyze in Excel pivot tables will only show columns set to True. | |
| 42 | +| [SortByColumn] | The sort by column of each column in this semantic model as a string. Shows as blank when sorting by itself. | |
| 43 | +| [GroupingBehavior] | The grouping behavior of each column in this semantic model as a string. | |
| 44 | +| [SourceProviderType] | The source provider type of each column in this semantic model as a string. | |
| 45 | +| [DisplayFolder] | The display folder of each column in this semantic model as a string. Nested folders shown with / and multiple folders separated by ;. | |
| 46 | +| [AlternateOf] | The alternate of property of each column in this semantic model as a string. | |
| 47 | +| [LineageTag] | The lineage tag of each column in this semantic model as a string. | |
| 48 | + |
| 49 | + |
| 50 | +## Remarks |
| 51 | + |
| 52 | +Can only be ran by users with write permission on the semantic model and not when live connected to the semantic model in Power BI Desktop. This function can be used in calculated tables, columns, and measures of a semantic model and will update when the model is refreshed. |
| 53 | + |
| 54 | +## Example 1 - DAX query |
| 55 | + |
| 56 | +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): |
| 57 | + |
| 58 | +```dax |
| 59 | +EVALUATE |
| 60 | + INFO.VIEW.COLUMNS() |
| 61 | +``` |
| 62 | + |
| 63 | +This DAX query returns a table with all of the columns of this DAX function. |
| 64 | + |
| 65 | +## Example 2 - DAX query with SELECTCOLUMNS and FILTER |
| 66 | + |
| 67 | +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): |
| 68 | + |
| 69 | +```dax |
| 70 | +EVALUATE |
| 71 | + // Select specific columns from the filtered result |
| 72 | + SELECTCOLUMNS( |
| 73 | + // Filter columns from the INFO.VIEW.COLUMNS() table |
| 74 | + FILTER( |
| 75 | + INFO.VIEW.COLUMNS(), |
| 76 | + // Exclude rows where DataCategory is "RowNumber" and Table is "xTables" |
| 77 | + [DataCategory] <> "RowNumber" && [Table] <> "xTables" |
| 78 | + ), |
| 79 | + // Show only these selected columns with new names where specified |
| 80 | + [Table], |
| 81 | + "Column", [Name], |
| 82 | + [Description], |
| 83 | + "DAX formula", [Expression], |
| 84 | + [DataCategory], |
| 85 | + [DataType], |
| 86 | + [IsHidden] |
| 87 | + ) |
| 88 | + // Order the result by Table and then by Column |
| 89 | + ORDER BY |
| 90 | + [Table], [Column] |
| 91 | +``` |
| 92 | + |
| 93 | +This DAX query returns a table with only the specified columns and rows meeting the filter condition with a DAX formula. |
| 94 | + |
| 95 | +:::image type="content" source="media/info-view-columns-function-dax/dax-query-example-2.png" alt-text="Screenshot showing the output of INFO.VIEW.COLUMNS() with selected columns in DAX query view." lightbox="media/info-view-columns-function-dax/dax-query-example-2.png"::: |
| 96 | + |
| 97 | +## Example 3 - calculated table with SELECTCOLUMNS and FILTER |
| 98 | + |
| 99 | +Either of the above examples work in a calculated table when the EVALUATE and ORDER BY keywords are removed and a table name added. Here is example 2 in a calculated table: |
| 100 | + |
| 101 | +```dax |
| 102 | +Columns in this semantic model = |
| 103 | +// Select specific columns from the filtered result |
| 104 | + SELECTCOLUMNS( |
| 105 | + // Filter columns from the INFO.VIEW.COLUMNS() table |
| 106 | + FILTER( |
| 107 | + INFO.VIEW.COLUMNS(), |
| 108 | + // Exclude rows where DataCategory is "RowNumber" and Table is "xTables" |
| 109 | + [DataCategory] <> "RowNumber" && [Table] <> "xTables" |
| 110 | + ), |
| 111 | + // Show only these selected columns with new names where specified |
| 112 | + [Table], |
| 113 | + "Column", [Name], |
| 114 | + [Description], |
| 115 | + "DAX formula", [Expression], |
| 116 | + [DataCategory], |
| 117 | + [DataType], |
| 118 | + [IsHidden] |
| 119 | + ) |
| 120 | +``` |
| 121 | +This calculated table shows the same information as the DAX query in example 2 in a table in the model itself. |
| 122 | + |
| 123 | +## Example 4 - measure |
| 124 | + |
| 125 | +The following measure can be added to count the number of text columns in a semantic model: |
| 126 | + |
| 127 | +```dax |
| 128 | +Number of text columns = |
| 129 | +COUNTROWS( |
| 130 | + FILTER( |
| 131 | + INFO.VIEW.COLUMNS(), |
| 132 | + [DataType] = "Text" |
| 133 | + ) |
| 134 | +) |
| 135 | +``` |
| 136 | +This will show a scalar value with the number of text columns in my model. |
| 137 | + |
| 138 | +This can be shown in a visual: |
| 139 | + |
| 140 | +:::image type="content" source="media/info-view-columns-function-dax/measure-example-4-visuals.png" alt-text="Screenshot showing the output of INFO.VIEW.COLUMNS() with a measure then used in report visuals." lightbox="media/info-view-columns-function-dax/measure-example-4-visuals.png"::: |
| 141 | + |
| 142 | +Or a DAX query in [DAX query view](/power-bi/transform-model/dax-query-view): |
| 143 | + |
| 144 | +```dax |
| 145 | +DEFINE |
| 146 | + MEASURE 'Columns in this semantic model'[Number of text columns] = |
| 147 | + COUNTROWS( |
| 148 | + FILTER( |
| 149 | + INFO.VIEW.COLUMNS(), |
| 150 | + [DataType] = "Text" |
| 151 | + ) |
| 152 | + ) |
| 153 | +
|
| 154 | +EVALUATE |
| 155 | + SUMMARIZECOLUMNS( |
| 156 | + "Number of text columns", [Number of text columns] |
| 157 | + ) |
| 158 | +``` |
0 commit comments