How can I count the aggregate function in Tableau

0 votes

I have TOTAL as a calculated field on Tableau, which is further connected to R studio to create outputs through R

The R code has a function which is returning a bunch of 100 and 50 in a function passing .arg from Tableau, and these number will change if the parameter changes.

Calculated Field: TOTAL :

SCRIPT_STR("
    numbers <- function(a,b,c,parameter){
        a <- as.numeric(a)
        b <- as.numeric(b)
        c <- as.numeric(c)
        parameter <- as.numeric(parameter)
        al = ifelse(a > ((parameter * b) + b) | a < (c - (parameter * c)),'100','50')
        return(al)
    }
    numbers(.arg1,.arg2,.arg3,.arg4)
", SUM([A]),SUM([B]),SUM([C]),[PARAMETER])

Now, once I visualize the result (in a Pie Chart), I am not able to get the how many 100's or how many 50's are in there, but it is dividing the number proportion properly.

TOTAL result in Pie Chart TOTAL result in Pie Chart

Obviously the 100 in the first picture means one 100 of all the 100's that the output has, but I'd like to know the total of 100's and 50's

I tried to use COUNT over the TOTAL field, but it gave me an error that said TOTAL is already an aggregate function and it cannot be further aggregated.

Can someone help me to resolve this?

Apr 6, 2018 in Tableau by ghost
• 1,790 points
5,686 views

1 answer to this question.

0 votes

Create two calculated fields one for 100's and other for 50's

if Total = 100
then 1 
else 0
end

For counting 50's

if total=50
then 1
else 0
end

Finally take the running sum for both the calculated fields and add both the formulas in tool tip

answered Apr 6, 2018 by Atul
• 10,240 points

Related Questions In Tableau

0 votes
1 answer

How can I calculate the median of sales price using 3 variables in Tableau

First let me clarify things for you. ...READ MORE

answered Apr 12, 2018 in Tableau by xyz
• 1,560 points
7,055 views
0 votes
0 answers

How can I sort date field in presence of another date field in Tableau?

Goal: Sort the new ship date in ...READ MORE

Apr 10, 2018 in Tableau by ghost
• 1,790 points
1,379 views
0 votes
2 answers

How can I add text in the centre of a Donut Chart ?

Hi, You can read this for creating a donut ...READ MORE

answered Apr 4, 2019 in Tableau by Cherukuri
• 33,030 points
12,159 views
0 votes
1 answer

How can I add legends to worksheet in Tableau?

Just add the worksheet on the dashboard ...READ MORE

answered Apr 21, 2018 in Tableau by ffdfd
• 5,550 points
6,858 views
0 votes
1 answer

How to aggregate and count the occurrence of TRUE and FALSE?

Hi, you can do any of below ...READ MORE

answered Mar 12, 2019 in Tableau by Cherukuri
• 33,030 points
2,970 views
0 votes
1 answer

how to get the count of non zero values in a row

In first part you should solve the ...READ MORE

answered Apr 4, 2018 in Tableau by Atul
• 10,240 points
3,108 views
0 votes
1 answer

How to use LOD to count distinct number of records based on some condition?

From the desired output it seems that ...READ MORE

answered Apr 9, 2018 in Tableau by xyz
• 1,560 points
17,395 views
0 votes
1 answer

How to count occurrence of value and percentage of a subset in tableau public?

Although it sounds like a fairly easy ...READ MORE

answered Jun 5, 2018 in Tableau by Atul
• 10,240 points
11,783 views
0 votes
1 answer

How can I use COUNTD function in Tableau?

First add Col1 to the Columns shelf. Then ...READ MORE

answered May 9, 2018 in Tableau by Atul
• 10,240 points
8,539 views
0 votes
1 answer

How can I remove { } from columns in Tableau?

Create the following calculated field and use ...READ MORE

answered Aug 10, 2018 in Tableau by Atul
• 10,240 points
968 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