Datediff calculated field

Hi!
I’m trying to use the datediff function in a new calculated field. I want the result to be the number of hours from the beginning of the alert (field “time of alert”) until the closest Sunday at 05:00. For example, if the time of alert is Friday 03:00, the result should be 26 hours.

image
In this case - what should I write in the ‘X’ mark?

Thank you and have a good week!

1 Like

Hello @shirakoresh - Thank you for posting your query. I would follow 3 steps to achieve what you are trying to get. Please find the same below along with the relevant snapshot of the calculations below.

Step 1 : Create a Calculated Field where you will dynamically calculate the Nearest Sunday’s 05:00 Hrs in Date Time Format
Step 2 : Create another Calculated Field named Difference to compute the difference between the original DateTime field and this calculated field created in the above step
Step 3: Project this final “Difference” field in the visual

Hope this helps!

Did my suggestion help you in resolving your query? If yes, would request you to mark the post as “Solution”. This will help the community to find guidance and answers to similar question. Thank you!

1 Like

Thank you!. What do I need to change in the query to do the same for Monday 05:00? I saw in the Truncdate function guide that the week starts on Sunday in Amazon QuickSight.

@shirakoresh - Add 8 Days instead of 7 to get to the nearest upcoming Monday. Change the number 7 in the Calculated Field to 8. Hope this helps!

Did my suggestion help you in resolving your query? If yes, would request you to mark the post as “Solution”. This will help the community to find guidance and answers to similar question. Thank you!

1 Like