Forum Discussion

KMEAGHER's avatar
KMEAGHER
Icon for Advocate II rankAdvocate II
7 months ago
Solved

Difference by period column calc

Hi! I'm hoping to create a new column which displays the difference in 'Completed Current Cycle' between one date and the next, by Name in the table below. In other words, for each unique Name I want...
  • DataVitalizer's avatar
    7 months ago

    Hi KMEAGHER 


    Try using this DAX calculated column (Replace 'YourTableName' with your actual table name):

     

    New Completed = VAR CurrentCompleted = [Completed Current Cycle]
    VAR CurrentDate = [Date]
    VAR CurrentName = [School Code]
    VAR PreviousCompleted =     CALCULATE(
            MAX([Completed Current Cycle]),
            FILTER(
                ALL('YourTableName'),
                'YourTableName'[School Code] = CurrentName &&
                'YourTableName'[Date] < CurrentDate        )
        )
    RETURN
        IF(ISBLANK(PreviousCompleted), CurrentCompleted, CurrentCompleted - PreviousCompleted)

     

    Did it work? 👍 A kudos would be appreciated
    🟨 Mark it as a solution to help spread knowledge 💡

    🟩 Let's connect on LinkedIn