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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Sofiya
New Member

A date column adjacent to a date column

Sofiya_0-1710302595983.png

Sofiya_2-1710302671579.png

ORD_IDMLSTN_CDRECEIVED DATEACTUAL DATE
100HOB78614013-Mar-202321-Mar-2023
100HOB78614213-Mar-20237-Apr-2023
100HOB78614217-Mar-20238-Apr-2023
100HOB78614222-Mar-202311-Apr-2023
100HOB786322-Mar-202322-Mar-2023
100HOB78614223-Mar-202310-Apr-2023
100HOB786324-Mar-202322-Mar-2023
100HOB78614227-Mar-202310-Apr-2023
100HOB78614228-Mar-20239-Apr-2023
100HOB78614230-Mar-20239-Apr-2023
100HOB78614231-Mar-202311-Apr-2023
100HOB7861423-Apr-202312-Apr-2023
100HOB7861424-Apr-202312-Apr-2023
100HOB7861425-Apr-202311-Apr-2023
100HOB7861426-Apr-202311-Apr-2023
100HOB7861427-Apr-202310-Apr-2023
100HOB78614210-Apr-20239-Apr-2023
100HOB786210-Apr-202310-Apr-2023

 

Query is in the image from the same table attched and pasted here.

2 REPLIES 2
SamInogic
Super User
Super User

Hi @Sofiya ,

You can also try below DAX expression for the requirement,

AlertStatus =
VAR TargetDate = 'Table'[ACTUAL DATE] - 5
VAR ReceivedAlert =
    CALCULATE(
        COUNTROWS('Table'),
        'Table'[RECEIVED DATE] = TargetDate
    )
VAR AdjacentDate =
    IF(
        ReceivedAlert > 0,
        CALCULATE(
            VALUES('Table'[ACTUAL DATE]),
            'Table'[RECEIVED DATE] = TargetDate
        )
    )
VAR WithinRange =
    IF(
        NOT(ISBLANK(AdjacentDate)),
        IF(
            'Table'[ACTUAL DATE] - AdjacentDate <= 1 && 'Table'[ACTUAL DATE] - AdjacentDate >= -1,
            1,
            0
        ),
        0
    )
RETURN
    WithinRange

SamInogic_0-1710311264005.png

 

Thanks!

Inogic Professional Service Division

An expert technical extension for your techno-functional business needs

Power Platform/Dynamics 365 CRM

Drop an email at crm@inogic.com

Service:  http://www.inogic.com/services/ 

Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/




talespin
Solution Sage
Solution Sage

hi @Sofiya 

 

There were lot of questions, so I made some assumptions.

1. Arrival date of Parcel is where MLSTN_CD value is minimum.

2. What if there are multiple records for 5th April(Received Date)?

 

Create this as Measure.

 

Flag =

VAR _SelOrder = SELECTEDVALUE(Orders[ORD_ID])
VAR _MinMLSTN = CALCULATE( MIN(Orders[MLSTN_CD]), REMOVEFILTERS(), Orders[ORD_ID] = _SelOrder)
VAR _ActualDate = CALCULATE( MIN(Orders[ACTUAL DATE]), REMOVEFILTERS(), Orders[ORD_ID] = _SelOrder && Orders[MLSTN_CD] = _MinMLSTN)
VAR _AlertDate = (_ActualDate - 5)
VAR _ActualDate2 = CALCULATE( MIN(Orders[ACTUAL DATE]), REMOVEFILTERS(), Orders[ORD_ID] = _SelOrder && Orders[RECEIVED DATE] = _AlertDate)

RETURN IF( _ActualDate2 = (_ActualDate + 1) || _ActualDate2 = (_ActualDate - 1), 1, 0)
 
talespin_0-1710309815624.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.