Forum Discussion

mohammedismail's avatar
5 years ago
Solved

Help: Select Dates for a Measure Dynamically

Hi,   I'm stuck in a situation where I need to enter dates Dynamically using any input option that is available.I'm using the below measure - can someone help ?   Spend = CALCULATE(Invoice_Spend...
  • BA_Pete's avatar
    BA_Pete
    5 years ago

    mohammedismail ,

     

    Are you using Calendar[Date] in the SAMEPERIODLASTYEAR function?

    The contiguous selection error usually shows when you try to implement time intelligence functions (DATESYTD, SAMEPERIODLASTYEAR etc.) using the date field from your fact table (where there isn't always contiguous dates) instead of using the date field from your calendar table (where there ARE contiguous dates by definition).

     

    Your measures should look something like this:

     

    //Measure for current year value
    _invoiceSpend = SUM(Invoice_Spend[Invoice Spend])
    
    //Measure for prior year value
    _invoiceSpendPY =
    CALCULATE(
      [_invoiceSpend],
      SAMEPERIODLASTYEAR(Calendar[Date])
    )

     

     

    Using these measures with a BETWEEN slicer containing Calendar[Date] should do exactly what you want.

     

    Pete