Forum Discussion

a_nijsten's avatar
a_nijsten
Regular Visitor
2 years ago
Solved

Selecting rows with slicer doesn't work

Hello,

I am stuck with a Power BI problem.

In the model there is a data table (Testdata) and a date table (Datetable). In the slicers, I have selected the year 2024 and the month of May. Based on these slicers, I would like to see all rows with a start date <= 31-05-2024 and an end date >= 01-01-2024 or empty. But it is not working.

I am only getting the rows with a start date in May, but I also want to include the rows that started before May and have an end date in or after May or are not filled in at all.

You could solve this problem by setting dates in the filters, but then you would have to adjust these with every change. Therefore, I want to solve this with a single click via a slicer.

 

Please find enclosed PBIX and expected result. https://we.tl/t-6LHcCD5Juj 


Who can help me with this?

 

Thank you in advance!

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi,

    Thanks for the solution Ashish_Mathur  and elitesmitpatel  and foodd  provided, and i want to offer some more infotmation for user to refer to.

    hi a_nijsten , you can create a measure

    MEASURE =
    VAR a =
        MAX ( Datetable[Date] )
    VAR b =
        EOMONTH ( a, -1 ) + 1
    RETURN
        CALCULATE (
            COUNTROWS ( Testdata ),
            Testdata[Startdate] <= a,
            OR ( Testdata[Enddate] >= b, Testdata[Enddate] = BLANK () ),
            CROSSFILTER ( Datetable[Date], Testdata[Startdate], NONE )
        )
    

    Outptut

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

8 Replies