Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Comparing latest value to previous

Hi There,   I am trying to compare latest value for each area(North, East e.t.c) to previous month value to see if it is more, and also trying to see if latest value is more than the target. i.e.  ...
  • v-zhangti's avatar
    4 years ago

    Hi, Anonymous 

    1. For your first question, check whether the value of this month is greater than the target value, create a calculation column "Compare Target", if it exceeds the target value, output Yes, otherwise No.
    Compare Target =
    IF (
        CALCULATE (
            MIN ( 'Table'[Value] ),
            FILTER (
                'Table',
                'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
                    && 'Table'[Attribute] = EARLIER ( 'Table'[Attribute] )
            )
        ) > 'Table'[Target],
        "Yes",
        "No"
    )
    

         2. For your second question, calculate the difference between the current month and the previous month. First create calculation columns to calculate the value of the previous month corresponding to each month in each region, and then calculate the difference.

    Last Month =
    DATEADD ( 'Table'[Attribute], -1, MONTH )
    
    Last Mouth Value =
    CALCULATE (
        MIN ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Attribute] = EARLIER ( 'Table'[Last Month] )
                && 'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
        )
    )
    
    Difference Value =
    'Table'[Value] - 'Table'[Last Mouth Value]
    

    The process of calculating the difference is shown in the figure:

          3. If you want to compare whether there are more values than last month, you can create a calculation column "Compare Last Month Value". If there are more values than last month, you will output Yes, otherwise, you will No.

    Compare Last Mouth Value =
    IF (
        CALCULATE (
            MIN ( 'Table'[Value] ),
            FILTER (
                'Table',
                'Table'[Attribute] = EARLIER ( 'Table'[Last Month] )
                    && 'Table'[Viewings] = EARLIER ( 'Table'[Viewings] )
            )
        ) < 'Table'[Value],
        "Yes",
        "No"
    )
    

    Best Regards,

    Charlotte Zhang

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