# Report Rule Expression

## General Expression

### **Check Count of Objects**

The **`Count()`** function or, `Count` keyword is used to determine the number of elements within an object or collection. It's utilized without any parameters to count all elements or with specific conditions to count elements that meet certain criteria.

#### Example

* To verify if the count of visuals in a collection named **`Visuals`** is greater than 3:

```
Visuals.Count() > 3
```

* To check if visuals with a specific filter type exceed 4:

```
Visuals.Count(Filters.Any(FilterType == "TopN")) > 4
```

### **Check Bool Values**

This expression compares a property or variable to a Boolean value (**`true`** or **`false`**) to evaluate a condition.

#### Example

* To evaluate if a property **`IsInUse`** is **`False`**:

```
IsInUse == False
```

### **Check Value is Null or Empty**

The **`string.IsNullOrWhitespace(propertyName)`** is a method used to check if a string variable named **`propertyName`** is null, empty, or consists only of whitespace characters.

#### Example

* To ensure **`ShowAllRoles`** is not null or empty:

```
!string.IsNullOrWhitespace(ShowAllRoles)
```

### **Check Multiple Levels**

This expression accesses properties or methods of nested objects by chaining their names together.

#### Example

To check if the count of fields in a single visual within the **`Config`** object exceeds 7:

```
Config.SingleVisual.Fields.Count() > 7
```

### **Check Value Contains Some Text**

This expression checks if a string contains a specific sequence of characters.

#### Example

To verify if an object type contains the text "Measure":

```
ObjectType.Contains("Measure")
```

## Report Scope

When the score of the rule is set to `Report` then, we can add/edit LINQ expression as shown in the following examples:

#### Examples

To retrieve the name property of the base theme used in the report:

```
BaseTheme.Name
```

To calculate the total number of pages within the report:

```
Pages.Count()
```

To verify whether the default cross-filtering behavior is set to true in the report configuration:

```
Config.DefaultDrillFilterOtherVisuals == "true"
```

To check if there are any custom visuals present in the report by verifying the count of such visuals:

```
CustomVisuals.Count > 0
```

## Page Scope

When the score of the rule is set to `Page` then, we can add/edit LINQ expression as shown in the following examples:

#### Examples:

To check if the current page is hidden based on the configuration settings.

```
Config.IsHidden == true
```

Verifies if there are more than two visuals present on the current page.

```
Visuals.Count > 2
```

Check for the existence of any filters applied at the page level.

```
Filters.Any()
```

Assesses whether there is any visual on the page with a width greater than 500 units.

```
Visuals.Any(Width > 500)
```

Verifies if all visuals across all pages have a width greater than 500 units.

```
Visuals.All(Width > 500)
```

## Visual Scope

When the score of the rule is set to `Visual` then, we can add/edit LINQ expression as shown in the following examples:

#### Examples:

Check if the name property of visual matches the specified name "Visual Name".

```
Name == "Visual Name"
```

Examines whether there are any filters applied at the visual level.

```
Filters.Any()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.powerops.app/powerops/best-practices/report-rules/edit-rules/report-rule-expression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
