Daily DAX : Day 273 ISTEXT

 The **ISTEXT** function in Power BI's Data Analysis Expressions (DAX) checks whether a given value is a text string. It returns **TRUE** if the value is text and **FALSE** if it is not.


### Syntax

```dax

ISTEXT(value)

```


- **value**: The expression or column value to be evaluated.


### Return Value

- **TRUE**: If the value is a text string.

- **FALSE**: If the value is not a text string (e.g., number, date, blank, or other data types).


### How It Works

The **ISTEXT** function is used to validate or filter data based on whether a value is text. It’s particularly useful in data cleansing, conditional logic, or calculated columns where you need to identify text values in a dataset.


### Use Cases

1. **Data Validation**:

   - Check if a column contains text values before performing operations that require text, such as concatenation or string manipulation.

   - Example: Ensure a column meant to store names or IDs is text-based.


2. **Conditional Formatting**:

   - Use **ISTEXT** in a calculated column or measure to apply conditional logic, such as flagging non-text entries in a column for review.


3. **Data Cleansing**:

   - Identify and filter out non-text values in a column that should only contain text, helping to spot data entry errors.


4. **Dynamic Calculations**:

   - Combine with other DAX functions like **IF** to handle text and non-text values differently in calculations.


### Example

Suppose you have a table `CustomerData` with a column `CustomerID` that should contain text-based IDs, but some entries might be numeric or blank due to data issues.


#### DAX Formula

```dax

IsTextCustomerID = ISTEXT(CustomerData[CustomerID])

```


- This creates a calculated column that returns **TRUE** for text values in `CustomerID` and **FALSE** for non-text values (e.g., numbers, blanks, or dates).


#### Practical Scenario

You can use the calculated column to filter or create a measure to count invalid entries:

```dax

InvalidCustomerIDs = 

CALCULATE(

    COUNTROWS(CustomerData),

    CustomerData[IsTextCustomerID] = FALSE

)

```


This measure counts rows where `CustomerID` is not text, helping identify data quality issues.


### Notes

- **ISTEXT** is case-insensitive and considers only the data type, not the content of the text.

- If the value is blank, **ISTEXT** returns **FALSE**.

- It’s often used with other DAX functions like **IF**, **FILTER**, or **CALCULATE** for more complex logic.


### Limitations

- **ISTEXT** only checks the data type, not the format or content (e.g., it doesn’t validate if a text string is a valid email or phone number).

- It doesn’t handle arrays or lists; it evaluates single values.


Comments

Popular posts from this blog

Daily DAX : Day 65 INFO.TABLEPERMISSIONS

Daily DAX : Day 55 PV