Forum Discussion

rmcgrath's avatar
rmcgrath
Advocate II
1 year ago
Solved

Dynamic date parameters?

Hello.  I would like to modify the following code snippet to refer to (2) cells in an Excel workbook (a cell for a start date and a cell for an end date)

 
VAR __DS0FilterTable5 = 
FILTER(
KEEPFILTERS(VALUES('Date Dim'[FiscalBaseDate])),
AND(
'Date Dim'[FiscalBaseDate] >= DATE(2024, 1, 1),
'Date Dim'[FiscalBaseDate] < DATE(2024, 2, 15)
  • You have loaded the data to power bi model right ? and if you are on live connection like direct mode then i think it will not load but only query it so try switching to import 
    another way is you could use what if parameter instead of the parameter table itslef i guess

5 Replies

  • Hi Could you try this

    VAR __StartDate =
    CALCULATE(
    MAX('ParameterTable'[ParameterValue]),
    'ParameterTable'[ParameterName] = "StartDate"
    )

    VAR __EndDate =
    CALCULATE(
    MAX('ParameterTable'[ParameterValue]),
    'ParameterTable'[ParameterName] = "EndDate"
    )

    VAR __DS0FilterTable5 =
    FILTER(
    KEEPFILTERS(VALUES('Date Dim'[FiscalBaseDate])),
    AND(
    'Date Dim'[FiscalBaseDate] >= __StartDate,
    'Date Dim'[FiscalBaseDate] < __EndDate
    )
    )
    If the post helped please give a kudos and accept this as a solution
    Thanks in advance

    • rmcgrath's avatar
      rmcgrath
      Advocate II

      Hi - probably a dumb question, but where are you getting "Parameter Table" from?

      • Akash_Varuna's avatar
        Akash_Varuna
        Super User

        Sorry didnt share that as you need to create a table for that Prameter Table for start date and end date which will then dynamically filter without hardcoding it into DAX