How to use COUNTIF in Tableau

0 votes

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 by ghost
• 1,790 points
36,326 views

6 answers to this question.

0 votes

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 :

enter image description here

answered May 10, 2018 by ffdfd
• 5,550 points
0 votes

Use this lod expression:

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

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
0 votes

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
0 votes

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

Related Questions In Tableau

0 votes
1 answer

How to use a IFF statement in Tableau

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

answered Apr 5, 2018 in Tableau by QueenBee
• 1,820 points
1,916 views
0 votes
1 answer

how to use/access Json data in Tableau?

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

answered Mar 19, 2019 in Tableau by Cherukuri
• 33,030 points
3,830 views
0 votes
1 answer

How to use stored procedures in Tableau?

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

answered Jun 10, 2019 in Tableau by Cherukuri
• 33,030 points
9,609 views
0 votes
1 answer

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

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

answered Mar 27, 2018 in Tableau by Atul
• 10,240 points
9,892 views
0 votes
1 answer

Creating a calculated field with LOD expression

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

answered Apr 20, 2018 in Tableau by ffdfd
• 5,550 points
1,172 views
+1 vote
1 answer

Adding filter to LOD Expression

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

answered Aug 1, 2018 in Tableau by Atul
• 10,240 points
1,040 views
0 votes
1 answer

Exclude LOD -Tableau

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

answered Apr 2, 2019 in Tableau by Cherukuri
• 33,030 points
649 views
0 votes
1 answer

INCLUDE LOD- tableau

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

answered Apr 2, 2019 in Tableau by Cherukuri
• 33,030 points
571 views
0 votes
1 answer

How can I use Tableau to create a heatmap?

Step 1: Create an Excel Spreadsheet with ...READ MORE

answered Apr 2, 2018 in Tableau by ffdfd
• 5,550 points
2,909 views
0 votes
1 answer

How to get Tableau results in python?

Well even I was looking for the ...READ MORE

answered Apr 9, 2018 in Tableau by ffdfd
• 5,550 points
900 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP