Forum Discussion

julsr's avatar
julsr
Icon for Continued Contributor rankContinued Contributor
1 year ago
Solved

Generate dynamic table for dates based on a specific field is not working

Hi everyone,

 

I have this issue and I'm trying to implement what was suggested there. However, the problem is that it's not generating the dynamic table for the dates, although it works when I put the date hardcoded.

 

DateRangeFilter =
VAR SelectedDateRaw = CALCULATE(
    MIN('dummy-sales-data'[Fecha]),
    ALLSELECTED('dummy-sales-data'[Fecha])
)
RETURN
GENERATESERIES(
    DATE(YEAR(SelectedDateRaw), MONTH(SelectedDateRaw), 1),
    --DATE(2024,01,27), --With this it works
SelectedDateRaw  -- this doesn't work
    1
)
 
Here's the file and the table is the one named DateRangeFilter. What's wrong?
 
Thanks
  • You're correct—calculated tables don't respond to slicer selections. However, you can use a measure to visually filter a dates table, which works well as long as range options like "Between," "Before," or "After" aren't used. In the screenshot below, my reference date, February 11, is applied in the DateFilter measure to count rows in a disconnected slicer within a week relative to that date. This filters the dates effectively in a vertical list slicer but not in a slider.

     

    An alternative approach is to create a dates table that includes additional rows for dates starting from a specific date. Refer to the screenshot below for an example.

     

4 Replies

  • julsr 

    DateRangeFilter = 
    VAR SelectedDateRaw =
    VALUE(
    CALCULATE(
    MIN('dummy-sales-data'[Fecha]),
    ALLSELECTED('dummy-sales-data'[Fecha])
    )
    )
    RETURN
    GENERATESERIES(
    DATE(YEAR(SelectedDateRaw), MONTH(SelectedDateRaw), 1),
    SelectedDateRaw,
    1
    )
    💡 If this helped, please give Kudos 👍 or mark it as a Solution .
    Best regards,
    Kedar
    🌐 Connect on LinkedIn
  • Hi julsr 

     

    Calculated tables update only during a refresh, when their formula is modified, or when changes occur in the underlying columns or tables. They do not respond to slicer selections. In the example below, the variable will consistently return 1/1/2024, the min value of 'dummy-sales-data'[Fecha].

     

    VAR SelectedDateRaw = CALCULATE(
        MIN('dummy-sales-data'[Fecha]),
        ALLSELECTED('dummy-sales-data'[Fecha])
    )

     

    • julsr's avatar
      julsr
      Icon for Continued Contributor rankContinued Contributor

      Thanks Kedar_Pande , that's what I've done and explained in this thread and it's not working but it works when I hardcode the date.

      danextian , thanks. So you're saying that it's not possible to create a dynamic table for dates based on a slicer? For example, if I pick the date 2024/12/24 in a slicer, it should make a table with dates from 2024/12/01 to 2024/12/24.

      If it's not possible, can I use the selected date to filter the end date in another slicer (a slicer with a Between functionality which has start and end date) that's on another page?

       

      thanks!

      • danextian's avatar
        danextian
        Icon for Super User rankSuper User

        You're correct—calculated tables don't respond to slicer selections. However, you can use a measure to visually filter a dates table, which works well as long as range options like "Between," "Before," or "After" aren't used. In the screenshot below, my reference date, February 11, is applied in the DateFilter measure to count rows in a disconnected slicer within a week relative to that date. This filters the dates effectively in a vertical list slicer but not in a slider.

         

        An alternative approach is to create a dates table that includes additional rows for dates starting from a specific date. Refer to the screenshot below for an example.