Forum Discussion

shower999's avatar
shower999
Frequent Visitor
7 years ago
Solved

Lookupvalue Last Quarter in the same table without aggregation

Dear all,   I'm new to PowerBI DAX language. I have a combined each month customer statuses and would like to compare their changes month over month. Customer is unique in each month   essential...
  • v-yulgu-msft's avatar
    7 years ago

    Hi shower999,

     

    Please refer to below DAX formulas to add calculated columns:

    Index =
    RANKX (
        FILTER ( Sample1, Sample1[Account] = EARLIER ( Sample1[Account] ) ),
        Sample1[Data_date],
        ,
        ASC,
        DENSE
    )
    
    Last_Mth_Profile =
    CALCULATE (
        SELECTEDVALUE ( Sample1[Profile] ),
        FILTER (
            ALLEXCEPT ( Sample1, Sample1[Account] ),
            Sample1[Index]
                = EARLIER ( Sample1[Index] ) - 1
        )
    )
    
    Profile_Changes =
    IF (
        Sample1[Account] = BLANK (),
        "Off boarded",
        IF (
            Sample1[Last_Mth_Profile] = BLANK ()
                || Sample1[Last_Mth_Profile] = Sample1[Profile],
            BLANK (),
            IF ( Sample1[Last_Mth_Profile] < Sample1[Profile], "Up", "Down" )
        )
    )
    
    Last_Mth_W_D =
    CALCULATE (
        SELECTEDVALUE ( Sample1[Warranty_date] ),
        FILTER (
            ALLEXCEPT ( Sample1, Sample1[Account] ),
            Sample1[Index]
                = EARLIER ( Sample1[Index] ) - 1
        )
    )
    
    Warranty_Changes =
    IF (
        Sample1[Account] = BLANK (),
        "Off boarded",
        IF (
            Sample1[Last_Mth_W_D] = BLANK ()
                || Sample1[Last_Mth_W_D] = Sample1[Warranty_date],
            BLANK (),
            IF ( Sample1[Last_Mth_W_D] < Sample1[Warranty_date], "Cancelled", "Extended" )
        )
    )
    

     

    Best regards,

    Yuliana Gu

  • shower999's avatar
    shower999
    7 years ago

    WoW!! this works perfectly. highly appreciated. I'll use these formulars across all my calculation.