Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
LinaP_
Frequent Visitor

Slicer with an OR argument

Hi all, 

In a report I have visualized "Planned delivery dates" and "Actual delivery dates" in a table with the order number (uniqe).

I have a mock version of the table here:

Order numberPlanned date (YYMMDD)Actual date (YYMMDD)Difference in days 
A12022-01-012022-02-0130
B22022-02-012022-01-15-15
C32022-03-012022-04-1545
D42022-04-012022-01-01-90
E52022-05-012021-05-01-365

 

I have added a slicer with relative date (ex. last 6 months) and have played around with Planned dates and Actual dates.

The problem is I always miss some data as the dates can differ quite significantly in time (+100 days in some cases). 

 

In my head the solution is quite simple, a slicer with Planned date OR Actual date occurring in the last X months. Anyone know if this is possible?  

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @LinaP_ ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a date dimension table and apply it to the slicer

Note: Please DO NOT create any relationship with the fact table

vyiruanmsft_1-1684897599708.png

2. Create a measure as below

Flag = 
VAR _selpdate =
    SELECTEDVALUE ( 'Table'[Planned date (YYMMDD)] )
VAR _seladate =
    SELECTEDVALUE ( 'Table'[Actual date (YYMMDD)] )
RETURN
    IF (
        (
            _seladate >= MIN ( 'Calendar'[Date] )
                && _seladate <= MAX ( 'Calendar'[Date] )
        )
            || (
                _seladate >= MIN ( 'Calendar'[Date] )
                    && _seladate <= MAX ( 'Calendar'[Date] )
            ),
        1,
        0
    )

3. Apply a visual-level filter on the visual with the condition(Flag is 1)

vyiruanmsft_0-1684897487255.png

Best Regards

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

View solution in original post

3 REPLIES 3
LinaP_
Frequent Visitor

Hi @v-yiruan-msft 

Thanks for the help! It captures all orders now that has an end date, which is more than I could solve! 😄

 

One issue still remains, which I did not include in my example, is that some of the "Actual" dates haven't happened yet:

Order numberPlanned (YYMMDD)Actual (YYMMDD)Difference in days
A12023-01-012023-01-010
B12023-01-012023-02-0130
C12023-05-012023-04-15-15
D12023-05-01 25

 

Do you have any idea on how to include that?

 

Warm Regards

v-yiruan-msft
Community Support
Community Support

Hi @LinaP_ ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a date dimension table and apply it to the slicer

Note: Please DO NOT create any relationship with the fact table

vyiruanmsft_1-1684897599708.png

2. Create a measure as below

Flag = 
VAR _selpdate =
    SELECTEDVALUE ( 'Table'[Planned date (YYMMDD)] )
VAR _seladate =
    SELECTEDVALUE ( 'Table'[Actual date (YYMMDD)] )
RETURN
    IF (
        (
            _seladate >= MIN ( 'Calendar'[Date] )
                && _seladate <= MAX ( 'Calendar'[Date] )
        )
            || (
                _seladate >= MIN ( 'Calendar'[Date] )
                    && _seladate <= MAX ( 'Calendar'[Date] )
            ),
        1,
        0
    )

3. Apply a visual-level filter on the visual with the condition(Flag is 1)

vyiruanmsft_0-1684897487255.png

Best Regards

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

Hi, 

Really appreciate the help! 

Needed to do a modification to work with blank dates as following: but now it works like a charm. 

 

Flag = 
VAR _selpdate =
    SELECTEDVALUE ( 'Table'[Planned date] )
VAR _seladate =
    IF ( ISBLANK ( SELECTEDVALUE ( 'Table'[Actual date] ) ), TODAY(), SELECTEDVALUE ( ''Table'[Actual date] ) )
RETURN
    IF (
        (
            _selpdate <= TODAY() &&
            (
                (
                    _selpdate >= MIN ( 'Calendar_for_measurment'[Date] )
                    && _selpdate <= MAX ( 'Calendar_for_measurment'[Date] )
                )
                ||
                (
                    _seladate >= MIN ( 'Calendar_for_measurment'[Date] )
                    && _seladate <= MAX ( 'Calendar_for_measurment'[Date] )
                )
            )
        ),
        1,
        0
    )

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.