Calculate Date Between two Parameter Dates to be used in periodtodatelastvalue

Hello @ThreeEleven, I want to make sure I understand the result you are looking for. You want to utilize the number of days between 2 selected dates to determine the number of days ahead of a row date field that you consider for a last value calculation? The overall expectation feels a little strange, so I want to make sure I understand.

Now, if you are wanting to compare values for each of the selected dates, that is something we could manage. Using sumOver aggregations, we could get the value for the first date and second date, and calculate a difference.

First Date Visitors = sumOver(ifelse({date field} = ${StartDate}, {visitors}, NULL), [], PRE_AGG)

Second Date Visitors = sumOver(ifelse({date field} = ${EndDate}, {visitors}, NULL), [], PRE_AGG)

Now you can find the difference between these 2 fields like this:

minOver({First Date Visitors}, [], PRE_AGG) - minOver({Second Date Visitors}, [], PRE_AGG)

I hope this helps provide some detail about the issue you are facing. If you need further guidance, please provide some more detail about the expected result of the calculation and I can guide you towards a solution. It may also be beneficial to create an analysis in Quick Sight Arena where we can work on a solution together. Thank you!