Kate E 2 Posted September 9, 2023 Share Posted September 9, 2023 I need help writing logic in calculated column to give results below. ID date ProdFlag NormTime XYZ1 8/31/2023 1 3 XYZ1 8/31/2023 1 3 XYZ1 7/31/2023 1 2 XYZ1 7/31/2023 1 2 XYZ1 7/31/2023 1 2 XYZ1 7/31/2023 1 2 XYZ1 6/30/2023 1 1 Link to comment Share on other sites More sharing options...
Kate E 2 Posted September 9, 2023 Author Share Posted September 9, 2023 For each ID and Date, I want to count production flag for normalized time but ONLY count once for each time and date.There is a data type column indicating production or forecast but I want to count for both so that can't be used as a filter. Link to comment Share on other sites More sharing options...
Gaia Paolini Posted September 11, 2023 Share Posted September 11, 2023 Did you mean to show the desired result? I am not sure I understand. Link to comment Share on other sites More sharing options...
Kate E 2 Posted September 11, 2023 Author Share Posted September 11, 2023 Thank you for reply. I added table as an example output for the normalized time calculation. I want to calculate a column which calculates normalized time but ONLY counts it once per individual date and ID. I.e. the table result example but this will be for hundreds of thousands of rows. Link to comment Share on other sites More sharing options...
Kate E 2 Posted September 11, 2023 Author Share Posted September 11, 2023 I tried making a ubique key adding the ID and the prod date and a case when prod flag >0 then unique count the unique key over all previous intersect date and ID but it freezes when calculating ( does not calculate after hours) Link to comment Share on other sites More sharing options...
Kate E 2 Posted September 11, 2023 Author Share Posted September 11, 2023 unique* Link to comment Share on other sites More sharing options...
Gaia Paolini Posted September 12, 2023 Share Posted September 12, 2023 sorry I really still do not understand what you want to calculate. The table shows four columns. Is one of them the desired result? It looks like you want to calculate NormTime but you say you need to calculate the new column 'once for each time and date'. So time is already known? Link to comment Share on other sites More sharing options...
Kate E 2 Posted September 12, 2023 Author Share Posted September 12, 2023 Yes- normalized time is the calculated column. I was just giving the specific notes as to how that should be calculated.I have raw data of ID and Date. I calculate the production flag( no issues ) and want to calculate normalized time column which would result in results consistent with the table. Link to comment Share on other sites More sharing options...
Jose Leviaguirre Posted September 12, 2023 Share Posted September 12, 2023 Will this help to create a new column called NormTime? If( DenseRank() Over (Partition By [ID] Order By [Date]) = 1, DenseRank() Over (Partition By [ID] Order By [Date]), DenseRank() Over (Partition By [ID] Order By [Date]) ) NormTime should increase by 1 for each unique combination of ID and Date. DenseRank assigns a rank to each unique combination of ID and Date based on the order of Date..If the rank is 1 for a particular combination, it assigns that rank as the NormTime value. And if it is greater than 1, assigns the same rank as 'NormTime' increases by 1 Link to comment Share on other sites More sharing options...
Kate E 2 Posted September 12, 2023 Author Share Posted September 12, 2023 I like suggestion but not seeing partition as a function in spotfire? Link to comment Share on other sites More sharing options...
Jose Leviaguirre Posted September 12, 2023 Share Posted September 12, 2023 Hello Katye, it was a way to illustrate the concept as I do not have enough data to work with. Try something like. or attach a larget sample dataset with desired output DenseRank() Over ([iD], [Date]) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now