Products | Versions |
---|---|
Spotfire Analyst | All |
If(Rank(Baserowid(),"asc",[myGroup1])=1,"First row of group","Duplicate")
If(Rank(Baserowid(),"asc",[myGroup1],[myGroup2],[myGroup3])=1,"First row of group","Duplicate")
You can also use the If() and Rank() logic shown above directly within calculations to include or exclude duplicates, as required:
Avg(if(Rank(baserowid(),"asc",[myGroup1])=1,[Value],Null))
Rank(baserowid(),"asc",[myGroup1])=1
myGroup | Value |
Yellow | 6 |
Yellow | 6 |
Yellow | 6 |
Blue | 3 |
Red | 9 |
Red | 9 |
(6+6+6+3+9+9)/6 = 6.5
if(Rank(baserowid(),"asc",[myGroup])=1,"First row of group","Duplicate")
myGroup | Value | Duplicate? |
Yellow | 6 | First row of group |
Yellow | 6 | Duplicate |
Yellow | 6 | Duplicate |
Blue | 3 | First row of group |
Red | 9 | First row of group |
Red | 9 | Duplicate |
Using this technique you can perform an average that will only look at a single value per grouping. For example:
myGroup | Value |
Yellow | 6 |
Blue | 3 |
Red | 9 |
And the average you would like to calculate would be:
(6+3+9)/3 = 6
Avg(if(Rank(baserowid(),"asc",[myGroup])=1,[Value],Null))
(6+3+9)/3 = 6