What I have? I am having a simple COUNTIF task in Excel

This is the data:

```ID   Metric   Scope   DynamicCalc
1    A1       TRUE    X
1    B1       FALSE   X
2    B1       TRUE    X
2    A1       FALSE   X
2    C1       FALSE   X
```

What I want?

I am facing issues in replicating the same COUNTIF task in tableau.The column 'DynamicCalc' should have the following values when Metric=A1 is selected: TRUE,TRUE,FALSE,FALSE,FALSE but in case B1 is selected it would be FALSE,FALSE,TRUE,TRUE,TRUE... so basically I want to assign a value of TRUE to the DynamicColumn if there is at least one TRUE in the Scope column to all rows for that ID.

May 10, 2018 in Tableau 35,802 views

## 6 answers to this question.

You can use the following LOD Expression to retrieve your desired result. Try using a calculated field like below:

```{FIXED [ID],[Metric]:MAX(if [Scope]='TRUE' then 'True' else 'False' end)}
```

When the Selection is B1 :

answered May 10, 2018 by
• 5,550 points

Use this lod expression:

```{FIXED [ID],[Metric]:MAX(if [Scope]='TRUE' then 'True' else 'False' end)
```
answered Dec 10, 2018 by Vedant
If you're using tableau version 9 or above, you can use different LOD expressions to achieve this.
answered Dec 10, 2018 by Deccan

You can use LOD expression for this purpose. LOD Expressions provide a way to easily compute aggregations that are not at the level of detail of the visualization. You can then integrate those values within visualizations in arbitrary ways.

answered Dec 10, 2018 by Pooja

There are three types of LOD expressions.

Fixed - FIXED level of detail expressions compute a value using the specified dimensions, without reference to the dimensions in the view.

Include - INCLUDE level of detail expressions compute values using the specified dimensions in addition to whatever dimensions are in the view.

Exclude - EXCLUDE level of detail expressions declare dimensions to omit from the view level of detail

answered Dec 10, 2018 by Vaibhav

I'll give you a brief idea on how to create LOD Expression:

1. Select Analysis Create Calculated Field.

2. In the Calculation editor that opens, do the following:

• Name the calculation, Sales Per Customer.

• Enter the following LOD expression:

{ INCLUDE [Customer Name] : SUM([Sales]) }

3. When finished, click OK.

The newly created LOD expression is added to the Data pane, under Measures.

For an in-depth explanation check out Tableau Training Course details.
answered Dec 10, 2018 by Haider

## How to use a IFF statement in Tableau

Use this syntax -  IIF(([Avg_sale] > [Today]),STR([Avg_sal ...READ MORE

## how to use/access Json data in Tableau?

Hi Sindhu, 1. Double click on Json on ...READ MORE

## How to use stored procedures in Tableau?

Hi Sindhu, Stored procedures are used to write ...READ MORE

## How to color code cells of a column based on the text value in Tableau

You can use the following steps to ...READ MORE

## Creating a calculated field with LOD expression

Go ahead and try the following three ...READ MORE

+1 vote

## Adding filter to LOD Expression

{ FIXED [Product]:COUNT(IF [Status]=0 THEN [Status] END)} Edit---- ...READ MORE

## Exclude LOD -Tableau

Hi Nikki, You can try this,  { EXCLUDE : ...READ MORE

## INCLUDE LOD- tableau

Hi Anitha, you can add a calculation like ...READ MORE