cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alumanah
Frequent Visitor

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. 

1. In the "North" the latest month value is greater than target
2. In the "North" the Difference between current month and previous month is ...
3. Value for previous month in the "North" is...

 

I there a way I can go about doing this with measures?

Viewing table.JPG

Really appretiate the help

 

Victor

Below is what the original data looks like

 

ViewingsTargetAprMayJunJulAugSep
North404034554030 
South503322874560 
East40342365445655
West607666876578 
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Alumanah 

  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"
)

vzhangti_0-1635215065236.png

     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:

vzhangti_2-1635215510694.png

      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"
)

vzhangti_3-1635215554468.png

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.

 

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @Alumanah 

  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"
)

vzhangti_0-1635215065236.png

     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:

vzhangti_2-1635215510694.png

      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"
)

vzhangti_3-1635215554468.png

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.

 

View solution in original post

Thank you so much this is perfect for what I am trying to acomplish

vanessafvg
Super User
Super User

please provide data in text format. 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors