Prompt
get distinct values from dataset
Answer
/*
Function: GetDistinctValues
This DAX function returns a table with distinct values from a specified column in a dataset.
Parameters:
- tableName: Name of the table containing the column with values
- columnName: Name of the column for which distinct values are to be retrieved
Return Type: Table
Exceptions:
- If the tableName or columnName provided does not exist in the dataset, an error will be raised.
*/
GetDistinctValues =
DISTINCT(SELECTCOLUMNS(tableName, "Distinct_Values", columnName))
Usage Example:
Suppose we have a table named 'Sales' with columns 'ProductID', 'Category', 'Quantity', and we want to get distinct values from the 'Category' column.
DistinctCategories = GetDistinctValues("Sales", "Category")
This will return a table with unique values from the 'Category' column in the 'Sales' table.
Description
The 'GetDistinctValues' DAX function retrieves unique values from a specified column in a dataset. It requires the table name and column name parameters. An error is raised if the provided table or column does not exist.
More Code Generators
Apache Flink Code GeneratorApache Pig Code GeneratorAzure Data Factory Code GeneratorC/C++ Code GeneratorCouchDB Code GeneratorDAX Code GeneratorExcel Code GeneratorFirebase Code GeneratorGoogle BigQuery Code GeneratorGoogle Sheets Code GeneratorGraphQL Code GeneratorHive Code GeneratorJava Code GeneratorJavaScript Code GeneratorJulia Code GeneratorLua Code GeneratorM (Power Query) Code GeneratorMATLAB Code GeneratorMongoDB Code GeneratorOracle Code GeneratorPostgreSQL Code GeneratorPower BI Code GeneratorPython Code GeneratorR Code GeneratorRedis Code GeneratorRegex Code GeneratorRuby Code GeneratorSAS Code GeneratorScala Code GeneratorShell Code GeneratorSPSS Code GeneratorSQL Code GeneratorSQLite Code GeneratorStata Code GeneratorTableau Code GeneratorVBA Code Generator