Forum Discussion

michael_knight's avatar
michael_knight
Icon for Post Prodigy rankPost Prodigy
5 years ago
Solved

Previous rather than MINX

Hi,   I recently posted a thread when I needed help converting an Excel theory to Power BI. I got some brilliant help on here, however I need to adjust it.   This is what I need to do (diff is th...
  • mahoneypat's avatar
    5 years ago

    Here is a column expression that does that.  Note that in your example pbix, I had to change the data type of the Total In column to number.

     

    Diff From Prev =
    VAR thissale = Theory[Total IN]
    VAR thisdate = Theory[Date Offer Accepted]
    VAR prevdate =
        CALCULATE (
            MAX ( Theory[Date Offer Accepted] ),
            ALLEXCEPT (
                Theory,
                Theory[Property Name]
            ),
            Theory[Date Offer Accepted] < thisdate
        )
    VAR prevsale =
        CALCULATE (
            SUM ( Theory[Total IN] ),
            ALLEXCEPT (
                Theory,
                Theory[Property Name]
            ),
            Theory[Date Offer Accepted] = prevdate
        )
    RETURN
        IF (
            ISBLANK ( prevsale ),
            BLANK (),
            thissale - prevsale
        )

     

    Regards,

    Pat