Forum Discussion

_bs_'s avatar
_bs_
Icon for Advocate I rankAdvocate I
1 year ago
Solved

Filter on start and end dates

I'm looking to create a slicer that filters the visual on Dates. However the visual will show measures relating to created date and end date, so the slicer needs to work for both scenarios but drive...
  • wardy912's avatar
    1 year ago

    Hi _bs_ 

     

     You need to duplicate your current date table and keep it disconnected (no relationships).

    Add the date from this disconnected table to a slicer

    Create another table as follows

     

    DateTypeSelector = DATATABLE("DateType", STRING, {{"CreatedDate"}, {"EndDate"}})

     

    Add this to a slicer

     

    Now create a measure that respects the selected date type, edit to fit your tables

     

    SelectedDateType = SELECTEDVALUE(DateTypeSelector[DateType])
    
    TicketsOpened =
    CALCULATE(
        COUNTROWS(FactTickets),
        FILTER(
            FactTickets,
            IF(
                SelectedDateType = "CreatedDate",
                FactTickets[CreatedDate] IN VALUES(DisconnectedDate[Date]),
                FactTickets[EndDate] IN VALUES(DisconnectedDate[Date])
            )
        )
    )

     You can use this for ticketsclosed as well.

    This will work independantly of other relationships.

     

    I hope this helps, please give a thumbs up and mark as solved if it does, thanks!