Can I create a calculated field based on controls?

Hi @ryanalbanamazon

yes, it can be easily done with one Date Parameter and 2 calculated fields. Here are the steps:

  1. Create a Date Parameter, call it ‘SelectDate’

  2. Create a calculated field called ‘Sales this Month’ with the following formula:

      ifelse(dateDiff(Date,${SelectDate},"MM") = 0, {Sales}, 0)
    
  3. Create another calculated field called ‘Sales Previous Month’ with the following formula:

      ifelse(dateDiff(Date,${SelectDate},"MM") = 1, {Sales}, 0)
    
  4. Create a Pivot Table with Sales (optional), Sales This Month and Sales Previous Month as Values. It should look like this:

  1. Go to the Date parameter and Add a control on the page. It will act as a date filter for your visual.

For more info please check this community post

Hope it helps,
GL