Sabsh
Sabsh

Reputation: 13

Return the first non-zero in a column/row in tableau

I am trying to return the appearance of first non-zeros in a row. The variable I want to return is Fiscal Year that when each customer first started to buy the product.

In my case, I would like to return the Year they first started. The first appearance of "1" in each row represents when they started for the first time, so I want to return the Year for that customer when that first number appears.

ID  1950    1951    1953    1955    1959    1965    1968    1972    1974    1975    1976    
1               1       1           1   1   1   1   
2                                   1               
3           1                       1       1       
4                   1                   1   1   1   
5               1                   1               
6                           1                       
7                   1                               
8                   1                           1   
9                                                   
10      1       1       1       1                   1

11          1           1       1       1           
12                      1                           

Upvotes: 0

Views: 567

Answers (1)

Sam M
Sam M

Reputation: 4166

Use a level-of-detail (LOD) calculation. An LOD allows you to apply a calculation, in this case min() to a dataset for a given set of dimensions. You will need to decide whether to used FIXED or INCLUDE for your particular situation (they behave differently in the presence of filters). I'm making an assumption that your ID column is a customer Id.

{ INCLUDE [ID] : Min([Fiscal Year])}

Much more info available in the online help documents at https://onlinehelp.tableau.com/current/pro/desktop/en-us/calculations_calculatedfields_lod_overview.html.

Upvotes: 1

Related Questions