Hi, I'm sure this is really easy and probably been asked before, but I just cant figure it out/find an answer. (I'm a Tableau noob)
I have a column of data, say something like below:
No. | Buy |
---|---|
1 | Yes |
2 | |
3 | Yes |
4 | Yes |
I want to add a column in my text table to say what percentage of the total rows has a "Yes" in it, i.e for the above data it would calculate 75%
Thanks very much
Guy,
Welcome to the forums!
How about something like:
WINDOW_SUM(SUM( IF Buy == "Yes" THEN 1 ELSE 0 END)) / WINDOW_SUM(SUM(1))
The IF...END statement is operating per Row and just adding a 1 when there is a "Yes". Those are then aggregated using the SUM and then all added together by the WINDOW_SUM from the numerator.
The denominator is just the WINDOW_SUM of a SUM(1) for each No.
Hope that helps!
Regards,
Joshua