Forum Discussion

Jyaul1122's avatar
Jyaul1122
Helper III
1 year ago
Solved

Dates based on Slicer selection

Hi, I have two tables Fact and Date table, both are link many to one with Fact(data_date) and Date table(Dates). Fact Table: Project Data_Date Actual Date Project1 5/22/2025 11/19/2030 ...
  • v-sshirivolu's avatar
    1 year ago

    Hi Jyaul1122 ,
    Thank you for reaching out to Microsoft Fabric community.

    I got this working and thought I’d share how I did it,
    I generated a separate slicer table from Fact[Data_Date] by creating a calculated table as shown below:
    Slicer_Date = DISTINCT(Fact[Data_Date])

    There’s no relationship between this table and any other — it’s just used for the slicer.

    Then I created a measure to check if each date in the matrix should be shown, based on the slicer selection:

    Show Column = VAR SelectedDate = SELECTEDVALUE(Slicer_Date[Data_Date])
    VAR ThisColumnDate = SELECTEDVALUE(Dates[Dates])
    RETURN
    IF (
        NOT ISBLANK(SelectedDate) &&
        NOT ISBLANK(ThisColumnDate) &&
        ThisColumnDate,
        1,
        0
         )

     

    And finally, this is the measure I used to get the actual date values in the matrix:

    Selected Actual Date =

    VAR SelectedDate = SELECTEDVALUE(Slicer_Date[Data_Date])
    VAR ThisDate = SELECTEDVALUE(Dates[Dates])
    VAR ThisProject = SELECTEDVALUE(Fact[Project])

    RETURN
    IF (
        NOT ISBLANK(SelectedDate) &&
        NOT ISBLANK(ThisDate) &&
        NOT ISBLANK(ThisProject) &&
        ThisDate <= SelectedDate,
        CALCULATE (
            MAX(Fact[Actual Date]),
            FILTER (
                Fact,
                Fact[Project] = ThisProject &&
                Fact[Data_Date] = ThisDate
            )
        )
    )

     

    In the matrix, I placed Dates[Dates] on the rows, Fact[Project] on the columns, and used the Selected Actual Date measure as the value. I also applied Show Column as a visual-level filter, setting it to 1 so that only columns on or before the selected date are displayed.

    The slicer uses the Slicer_Date table we set up initially.

    Everything is functioning as intended the matrix updates according to the selected date and displays only the relevant values up to that point.

    Please find the attached .pbix file for your reference

    Regards,
    Sreeteja.