Forum Discussion

mrfsca's avatar
mrfsca
Frequent Visitor
3 years ago
Solved

Creating a new column based on date differences and matching values

I'm having difficulty creating a DAX logic to create a new column 'intransit'[exception_date], where the values are derived from the difference between 'intransit'[ETA CHN] and 'GRN'[Receive Date PPC...
  • Mrxiang's avatar
    3 years ago
    Sure, I can help you with that. Here's the DAX logic to create the new column 'intransit'[exception_date]:
    
    ```
    intransit[exception_date] =
    IF(
        ISBLANK(intransit[ETA CHN]) || intransit[ETA CHN] <> GRN[Receive Date PPC],
        GRN[Receive Date PPC],
        BLANK()
    )
    ```
    
    This formula checks if the date in each row of 'intransit'[ETA CHN] is missing or different from the corresponding row in 'GRN'[Receive PPC]. If it is, then it enters that date into the 'intransit'[exception_date] column. Otherwise, it leaves the column blank.
    
    To create a new column to view 'intransit'[Invoice] based on 'intransit'[exception_date], you can use the following formula:
    
    ```
    intransit[Invoice Exception] =
    IF(
        NOT(ISBLANK(intransit[exception_date])),
        intransit[Invoice],
        BLANK()
    )
    ```
    
    This formula checks if the 'intransit'[exception_date] column is not blank. If it is not, then it enters the corresponding 'intransit'[Invoice] value into the 'intransit'[Invoice Exception] column. Otherwise, it leaves the column blank.
    
    I hope this helps! Let me know if you have any further questions.