Forum Discussion

gwaczoka23's avatar
gwaczoka23
Frequent Visitor
3 years ago
Solved

Creating new column with value from previous date

Hi, Please help me with this issue. I tried to get the answer here, but I didn't manage to.  https://community.powerbi.com/t5/Desktop/New-column-with-value-from-previous-last-date/m-p/2880164#M991...
  • v-yadongf-msft's avatar
    3 years ago

    Hi gwaczoka23 ,

     

    Please add an index column in Power Query:

     

    Please try following DAX to  create two new columns:

     

    Previous index =
    CALCULATE (
        MAX ( 'Table'[Index] ),
        FILTER (
            'Table',
            'Table'[Index] < EARLIER ( 'Table'[Index] )
                && 'Table'[Vendor] = EARLIER ( 'Table'[Vendor] )
        )
    )
    
    Previous flag_new = LOOKUPVALUE('Table'[Product flag],'Table'[Index],'Table'[Previous index])

     

     

    You will get the result you want:

    Best regards,

    Yadong Fang

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