Issue with calculated field in Quicksight

Hi @pankaj_kushwaha,

You need to ensure that both inputs to the dateDiff function are coming from either aggregated or non-aggregated fields (in your example it would need to be aggregated). I’ve used the sample data that you’ve provided and built a quick sample solution within the newly launched QuickSight Arena. For sake of readability, I’ve separated the calculated field into 3 fields. Using QuickSight Arena, you can dive deep into it my solution directly within the community.
Date diff to previous row

Combined, the calculation for the No of days since previous departure field would look like this:

dateDiff(lastValue({Departure Date},[{Departure Date} ASC],[{Train_id},{Departure Date}]),lag({Arrival Date},[{Arrival Date} ASC],1,[{Train_id}]))

Did this answer your question? If so, please help the community out by marking this answer as “Solution!”. Thanks!

3 Likes