Forum Discussion

PowerRobots99's avatar
PowerRobots99
Icon for Helper II rankHelper II
2 years ago
Solved

Date filling tricky challenge

Hi everyone,   I am having a table like this,  Now, for the first blank in Dates column (7/14/24 - 1212 - Blank) row, we have to get date value from previous week i.e 7/5/2024 and  for the secon...
  • lkalawski's avatar
    2 years ago

    Hi PowerRobots99 ,

     

    Below is the code that returns you the value from the previous known week for the selected PO.
    This is a calculated column that fills in values ​​that are empty.

    Correct Date = 
    VAR CurrentPO = [PO]
    VAR CurrentReportDate = [ReportDate]
    VAR PreviousReportDate =
        CALCULATE(
            MAX(comm[ReportDate]),
            FILTER(
                comm,
                comm[PO] = CurrentPO &&
                comm[ReportDate] < CurrentReportDate
            )
        )
    VAR LastDateInPreviousReportDate =
        CALCULATE(
            MAX(comm[Dates]),
            FILTER(
                comm,
                comm[PO] = CurrentPO &&
                comm[ReportDate] = PreviousReportDate &&
                NOT(ISBLANK(comm[Dates]))
            )
        )
    RETURN
        IF(
            ISBLANK([Dates]),
            LastDateInPreviousReportDate,
            [Dates]
        )

     

     Result:

     

    Memorable Member | Former Super User
    If I helped, please accept the solution and give kudos! 
    Linkedin